Exemple #1
0
        public JsonResult CurrentRoomList()
        {
            roomList.CleanRoom();
            List <string> inLobby = new List <string>();

            foreach (var player in playerList)
            {
                if (string.IsNullOrEmpty(player.RoomName))
                {
                    inLobby.Add(player.ConnectionId);
                }
            }
            if (roomList.Count > 0)
            {
                Clients.Clients(inLobby.ToArray()).CurrentRoomList(new JsonResult {
                    Data = new { data = JavaScriptObjectParser.Parse(roomList), hasRoom = true }
                });
            }
            else
            {
                //foreach (var client in inLobby)
                //{
                //    Clients.Client(client).CurrentRoomList(new JsonResult { Data = new { hasRoom = false } });
                //}
                Clients.Clients(inLobby.ToArray()).CurrentRoomList(new JsonResult {
                    Data = new { hasRoom = false }
                });
            }
            // Clients.AllExcept(inRoomIds.ToArray()).CurrentRoomList(new JsonResult { Data = new { data = JavaScriptObjectParser.Parse(roomList) } });
            return(new JsonResult {
                Data = new { data = JavaScriptObjectParser.Parse(roomList) }
            });
        }