Exemplo n.º 1
0
 public void SendToAllExcept(List <string> addressesToExclude, DetourMessage message)
 {
     if (addressesToExclude.Count == 1)
     {
         foreach (var item in RoomClients)
         {
             if (item.Key != addressesToExclude[0])
             {
                 Server.MessagesToSend.Enqueue(new SendableMessage
                 {
                     Address = item.Key,
                     Message = message
                 });
             }
         }
     }
     else
     {
         foreach (var item in RoomClients)
         {
             if (!addressesToExclude.Contains(item.Key))
             {
                 Server.MessagesToSend.Enqueue(new SendableMessage
                 {
                     Address = item.Key,
                     Message = message
                 });
             }
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 ///  Enqueues a Message to send to Address as JSON.
 /// </summary>
 public static void SendMessage(string Address, DetourMessage Message)
 {
     MessagesToSend.Enqueue(new SendableMessage
     {
         Address = Address,
         Message = Message
     });
 }
Exemplo n.º 3
0
 public void SendToAll(DetourMessage message)
 {
     foreach (var item in RoomClients.Values)
     {
         Server.MessagesToSend.Enqueue(new SendableMessage
         {
             Address = item.Id,
             Message = message
         });
     }
 }
Exemplo n.º 4
0
        /// <summary>
        ///  Called by the ClientContainer when message is received, runs it through the appropriate handler.
        /// </summary>
        public static void ReceivedMessage(string Address, DetourMessage v)
        {
            if (MessageTypeToMessageDefinition.ContainsKey(v.MessageType))
            {
                MessageTypeToMessageDefinition[v.MessageType].EventHandler(Address, v);
            }

            if (ServerReceivedMessage != null)
            {
                ServerReceivedMessage.Invoke(Address, v);
            }
        }
Exemplo n.º 5
0
        public static void RoomRequestReceived(string Address, DetourMessage RoomMessage)
        {
            Console.WriteLine("room request received");
            var _RoomMessageFromClient = RoomMessage as RoomRequestMessage;
            var _SelectedClient        = AllClients[Address];

            if (RoomTypes.ContainsKey(_RoomMessageFromClient.RequestedRoomType))
            {
                var successfulMatch = MatchToRoom(_RoomMessageFromClient.RequestedRoomType, _SelectedClient);
                if (successfulMatch != null)
                {
                    RoomTypes[_RoomMessageFromClient.RequestedRoomType].OnRoomJoined.Invoke(Address, successfulMatch, RoomMessage);
                }
            }
        }
Exemplo n.º 6
0
 public static void SendToRoomExcept(string RoomId, List <string> AddressesToExclude, DetourMessage Message)
 {
     Console.WriteLine("Sending to all except " + AddressesToExclude.Count);
     Rooms[RoomId].SendToAllExcept(AddressesToExclude, Message);
 }
Exemplo n.º 7
0
 public static void SendToRoom(string RoomId, DetourMessage Message)
 {
     Rooms[RoomId].SendToAll(Message);
 }