コード例 #1
0
 public ActionProcessor(ILog log, IDatabase data, ISubscriber sub, ConnectionToClient con)
 {
     logger     = log;
     database   = data;
     subscriber = sub; // sub should only be used to subscribe and unsubscribe from things, otherwise it just receives messages.
     connection = con;
 }
コード例 #2
0
        static void listener_NewConnection(ConnectionToClient conn)
        {
            Console.WriteLine("New connection {0}", conn.ClientName);
            conn.RouteMessage += conn_RouteMessage;
            conn.AddHandler("bye", HandleDisconnect);
            conn.AddHandler("ping", Pong);
            conn.AddHandler("get_uptime", GetUptime);
            conn.AddHandler("get_modules", GetModules);

            Clients.Add(conn);
        }
コード例 #3
0
ファイル: GameElement.cs プロジェクト: Kevin-Beck/Alzendor
 public void AddSubscriber(ConnectionToClient subscriber)
 {
     if (subscriber == null)
     {
         Console.WriteLine("Subscriber was null, returning from game element AddSubscriber");
         return;
     }
     if (subscribers == null)
     {
         subscribers = new List <ConnectionToClient>();
     }
     subscribers.Add(subscriber);
 }
コード例 #4
0
        static void conn_RouteMessage(ConnectionToClient conn, Message msg)
        {
            Console.WriteLine("Routing message \"{0}\" from \"{1}\" to \"{2}\"", Encoding.Unicode.GetString(msg.Data), msg.Source, msg.Destination);

            string dest = msg.Destination;

            if (Clients.Any(c => c.ClientName == dest))
            {
                Clients.First(c => c.ClientName == dest).SendMessage(msg);
            }
            else
            {
                Console.WriteLine("SHIT");
            }
        }
コード例 #5
0
 private void ReceiveHubDisconnectClientRequest(dynamic jsonData)
 {
     if (!Authentication.Current.Keys.Any(x => x.Key == jsonData["HubKey"]?.Trim()?.ToLower()))
     {
         ConnectionToClient.Close();
         return;
     }
     foreach (var clientID in jsonData["Clients"])
     {
         var client = AditServer.ClientList.Find(x => x.ID == clientID);
         if (client != null)
         {
             AditServer.ClientList.Remove(client);
             client.Socket.Close();
         }
     }
     SendHubDataRequest(jsonData["HubKey"]);
 }
コード例 #6
0
 private void ReceiveHubDeleteClientRequest(dynamic jsonData)
 {
     if (!Authentication.Current.Keys.Any(x => x.Key == jsonData["HubKey"]?.Trim()?.ToLower()))
     {
         ConnectionToClient.Close();
         return;
     }
     MainWindow.Current.Dispatcher.Invoke(() => {
         foreach (var client in jsonData["Clients"])
         {
             var computer = AditHub.Current.ComputerList.FirstOrDefault(x => x.ID == client);
             if (computer != null)
             {
                 AditHub.Current.ComputerList.Remove(computer);
             }
         }
         SendHubDataRequest(jsonData["HubKey"]);
     });
 }
コード例 #7
0
ファイル: GameElement.cs プロジェクト: Kevin-Beck/Alzendor
 public void RemoveSubscriber(ConnectionToClient subscriber)
 {
     subscribers.Remove(subscriber);
 }