종료시 컨넥션 정리
This commit is contained in:
@ -372,12 +372,26 @@ func (sh *subhandler) mainLoop(ctx context.Context) {
|
||||
return room
|
||||
}
|
||||
|
||||
defer func() {
|
||||
for _, conn := range entireConns {
|
||||
var roomnames []string
|
||||
for _, room := range conn.joinedRooms {
|
||||
roomnames = append(roomnames, room.name)
|
||||
}
|
||||
bt, _ := json.Marshal(roomnames)
|
||||
sh.callReceiver.OnClientMessageReceived(conn.sender, Disconnected, bytes.NewBuffer(bt))
|
||||
}
|
||||
}()
|
||||
|
||||
// 유저에게서 온 메세지, 소켓 연결/해체 처리
|
||||
for {
|
||||
buffer := bytes.NewBuffer(make([]byte, 0, 1024))
|
||||
buffer.Reset()
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
|
||||
case destroyedRoom := <-roomDestroyChan:
|
||||
delete(rooms, destroyedRoom)
|
||||
go sh.callReceiver.OnRoomDestroyed(sh.region, destroyedRoom)
|
||||
|
||||
Reference in New Issue
Block a user