Types for ConnectionID, NodeID, ParticipantKey (#450)
* Types for ConnectionID, NodeID, ParticipantKey * latest protocol version
This commit is contained in:
+12
-12
@@ -42,7 +42,7 @@ func (r *LocalRouter) GetNodeForRoom(_ context.Context, _ livekit.RoomName) (*li
|
||||
return node, nil
|
||||
}
|
||||
|
||||
func (r *LocalRouter) SetNodeForRoom(_ context.Context, _ livekit.RoomName, _ string) error {
|
||||
func (r *LocalRouter) SetNodeForRoom(_ context.Context, _ livekit.RoomName, _ livekit.NodeID) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ func (r *LocalRouter) RemoveDeadNodes() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *LocalRouter) GetNode(nodeID string) (*livekit.Node, error) {
|
||||
if nodeID == r.currentNode.Id {
|
||||
func (r *LocalRouter) GetNode(nodeID livekit.NodeID) (*livekit.Node, error) {
|
||||
if nodeID == livekit.NodeID(r.currentNode.Id) {
|
||||
return r.currentNode, nil
|
||||
}
|
||||
return nil, ErrNotFound
|
||||
@@ -76,7 +76,7 @@ func (r *LocalRouter) ListNodes() ([]*livekit.Node, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *LocalRouter) StartParticipantSignal(ctx context.Context, roomName livekit.RoomName, pi ParticipantInit) (connectionID string, reqSink MessageSink, resSource MessageSource, err error) {
|
||||
func (r *LocalRouter) StartParticipantSignal(ctx context.Context, roomName livekit.RoomName, pi ParticipantInit) (connectionID livekit.ConnectionID, reqSink MessageSink, resSource MessageSource, err error) {
|
||||
// treat it as a new participant connecting
|
||||
if r.onNewParticipant == nil {
|
||||
err = ErrHandlerNotDefined
|
||||
@@ -87,16 +87,16 @@ func (r *LocalRouter) StartParticipantSignal(ctx context.Context, roomName livek
|
||||
key := participantKey(roomName, pi.Identity)
|
||||
|
||||
// close older channels if one already exists
|
||||
reqChan := r.getMessageChannel(r.requestChannels, key)
|
||||
reqChan := r.getMessageChannel(r.requestChannels, string(key))
|
||||
if reqChan != nil {
|
||||
reqChan.Close()
|
||||
}
|
||||
resChan := r.getMessageChannel(r.responseChannels, key)
|
||||
resChan := r.getMessageChannel(r.responseChannels, string(key))
|
||||
if resChan != nil {
|
||||
resChan.Close()
|
||||
}
|
||||
reqChan = r.getOrCreateMessageChannel(r.requestChannels, key)
|
||||
resChan = r.getOrCreateMessageChannel(r.responseChannels, key)
|
||||
reqChan = r.getOrCreateMessageChannel(r.requestChannels, string(key))
|
||||
resChan = r.getOrCreateMessageChannel(r.responseChannels, string(key))
|
||||
|
||||
r.onNewParticipant(
|
||||
ctx,
|
||||
@@ -107,7 +107,7 @@ func (r *LocalRouter) StartParticipantSignal(ctx context.Context, roomName livek
|
||||
// response sink
|
||||
resChan,
|
||||
)
|
||||
return string(pi.Identity), reqChan, resChan, nil
|
||||
return livekit.ConnectionID(pi.Identity), reqChan, resChan, nil
|
||||
}
|
||||
|
||||
func (r *LocalRouter) WriteParticipantRTC(_ context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity, msg *livekit.RTCNodeMessage) error {
|
||||
@@ -115,12 +115,12 @@ func (r *LocalRouter) WriteParticipantRTC(_ context.Context, roomName livekit.Ro
|
||||
// create a new one
|
||||
r.rtcMessageChan = NewMessageChannel()
|
||||
}
|
||||
msg.ParticipantKey = participantKey(roomName, identity)
|
||||
msg.ParticipantKey = string(participantKey(roomName, identity))
|
||||
return r.writeRTCMessage(r.rtcMessageChan, msg)
|
||||
}
|
||||
|
||||
func (r *LocalRouter) WriteRoomRTC(ctx context.Context, roomName livekit.RoomName, msg *livekit.RTCNodeMessage) error {
|
||||
msg.ParticipantKey = participantKey(roomName, "")
|
||||
msg.ParticipantKey = string(participantKey(roomName, ""))
|
||||
return r.WriteNodeRTC(ctx, r.currentNode.Id, msg)
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ func (r *LocalRouter) rtcMessageWorker() {
|
||||
// consume messages from
|
||||
for msg := range r.rtcMessageChan.ReadChan() {
|
||||
if rtcMsg, ok := msg.(*livekit.RTCNodeMessage); ok {
|
||||
room, identity, err := parseParticipantKey(rtcMsg.ParticipantKey)
|
||||
room, identity, err := parseParticipantKey(livekit.ParticipantKey(rtcMsg.ParticipantKey))
|
||||
if err != nil {
|
||||
logger.Errorw("could not process RTC message", err)
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user