commandtype 이름 변경
This commit is contained in:
@ -61,7 +61,7 @@ type DownstreamMessage struct {
|
||||
type commandType string
|
||||
|
||||
const (
|
||||
commandType_JoinRoom = commandType("join_room")
|
||||
commandType_EnterRoom = commandType("enter_room")
|
||||
commandType_LeaveRoom = commandType("leave_room")
|
||||
)
|
||||
|
||||
@ -293,7 +293,7 @@ func (ws *WebsocketHandler) EnterRoom(region string, room string, accid primitiv
|
||||
sh := ws.subhandlers[region]
|
||||
if sh != nil {
|
||||
sh.localDeliveryChan <- &commandMessage{
|
||||
Cmd: commandType_JoinRoom,
|
||||
Cmd: commandType_EnterRoom,
|
||||
Args: []any{room, accid},
|
||||
}
|
||||
}
|
||||
@ -417,7 +417,7 @@ func (sh *subhandler) mainLoop(ctx context.Context) {
|
||||
}
|
||||
|
||||
case *commandMessage:
|
||||
if usermsg.Cmd == commandType_JoinRoom && len(usermsg.Args) == 2 {
|
||||
if usermsg.Cmd == commandType_EnterRoom && len(usermsg.Args) == 2 {
|
||||
roomName := usermsg.Args[0].(string)
|
||||
accid := usermsg.Args[1].(primitive.ObjectID)
|
||||
conn := entireConns[accid.Hex()]
|
||||
@ -479,7 +479,7 @@ func (sh *subhandler) mainLoop(ctx context.Context) {
|
||||
}
|
||||
|
||||
case *commandMessage:
|
||||
if usermsg.Cmd == commandType_JoinRoom && len(usermsg.Args) == 2 {
|
||||
if usermsg.Cmd == commandType_EnterRoom && len(usermsg.Args) == 2 {
|
||||
roomName := usermsg.Args[0].(string)
|
||||
accid := usermsg.Args[1].(primitive.ObjectID)
|
||||
conn := entireConns[accid.Hex()]
|
||||
@ -507,11 +507,15 @@ func (sh *subhandler) mainLoop(ctx context.Context) {
|
||||
case c := <-sh.connInOutChan:
|
||||
if c.Conn == nil {
|
||||
delete(entireConns, c.sender.Accid.Hex())
|
||||
var roomnames []string
|
||||
for _, room := range c.joinedRooms {
|
||||
roomnames = append(roomnames, room.name)
|
||||
room.out(c)
|
||||
}
|
||||
c.joinedRooms = nil
|
||||
go sh.callReceiver.OnClientMessageReceived(c.sender, Disconnected, nil)
|
||||
|
||||
bt, _ := json.Marshal(roomnames)
|
||||
go sh.callReceiver.OnClientMessageReceived(c.sender, Disconnected, bytes.NewBuffer(bt))
|
||||
} else {
|
||||
entireConns[c.sender.Accid.Hex()] = c
|
||||
go sh.callReceiver.OnClientMessageReceived(c.sender, Connected, nil)
|
||||
@ -542,7 +546,6 @@ func upgrade_core(sh *subhandler, conn *websocket.Conn, accid primitive.ObjectID
|
||||
}
|
||||
|
||||
if messageType == websocket.CloseMessage {
|
||||
sh.callReceiver.OnClientMessageReceived(c.sender, CloseMessage, r)
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user