コード例 #1
0
        public void RemovePlayer(string connectionId)
        {
            var player = playerRepository.GetByConnectionId(connectionId);

            if (player != null)
            {
                var room = roomRepository.GetByRoomId(player.RoomId);
                if (room != null)
                {
                    room.Remove(player);
                    if (room.IsRemovedAllPlayer)
                    {
                        AppSignalRLogger.Log("Remove Room {0}", room.RoomId);
                        roomRepository.Remove(room);
                    }
                    else
                    {
                        roomRepository.Save(room);
                    }
                }

                playerRepository.Remove(player);
            }
        }
コード例 #2
0
 public override Task OnDisconnectedAsync(Exception e)
 {
     AppSignalRLogger.Log("OnDisconnectedAsync {0}", Context.ConnectionId);
     appService.RemovePlayer(Context.ConnectionId);
     return(base.OnDisconnectedAsync(e));
 }
コード例 #3
0
 public override Task OnConnectedAsync()
 {
     AppSignalRLogger.Log("OnConnected {0}", Context.ConnectionId);
     appService.AddPlayer(Context.ConnectionId);
     return(base.OnConnectedAsync());
 }