public void Dispose()
 {
     MouseMover.Dispose();
     ArdLogger.Dispose();
     ArdServer.Dispose();
     MsgHub.Dispose();
 }
        public async Task RunServer()
        {
            MsgHub.Start();
            ArdLogger.Start();

            ArdServer.SystemStarted           += Server_ServerStarted;
            ArdServer.TcpEndpointConnected    += Server_TcpClientConnected;
            ArdServer.TcpEndpointDisconnected += Server_TcpClientDisconnected;
            ArdServer.TcpMessageReceived      += Server_TcpMessageReceived;
            ArdServer.TcpQueryReceived        += Server_TcpQueryReceived;
            ArdServer.TcpCommandReceived      += Server_TcpCommandReceived;

            ArdServer.Start();
            MouseMover.Start();


            while (true)
            {
                Console.Write("SEND: ");
                var inpt = Console.ReadLine();

                if (inpt.StartsWith("??"))
                {
                    var split      = inpt.TrimStart('?').Split(' ');
                    var qry        = split[0];
                    var qryArgs    = split.Skip(1).ToArray();
                    var resultTask = ArdServer.SendTcpQueryAsync(qry, qryArgs);
                    foreach (var e in await resultTask)
                    {
                        Server_TcpQueryResponseReceived(null, e);
                    }
                }
                else if (inpt.StartsWith("?"))
                {
                    var split   = inpt.TrimStart('?').Split(' ');
                    var qry     = split[0];
                    var qryArgs = split.Skip(1).ToArray();
                    //*/
                    ArdServer.SendTcpQuery(qry, qryArgs, Server_TcpQueryResponseReceived, null);

                    /*/
                     * var tokenSrc = new CancellationTokenSource();
                     * var qryArg = new RequestPushedArgs(qry, qryArgs, Server_TcpQueryResponseReceived, null, tokenSrc.Token, TimeSpan.FromMinutes(1));
                     * var qryMsg = new TcpQueryPushedMessage(this, qryArg);
                     * //tokenSrc.Cancel();
                     * MsgHub.EnqueueMessage(qryMsg);
                     * //*/
                }
                else if (inpt.StartsWith("!!"))
                {
                    var split      = inpt.TrimStart('!').Split(' ');
                    var cmdName    = split[0];
                    var cmdArgs    = split.Skip(1).ToArray();
                    var resultTask = ArdServer.SendTcpCommandAsync(cmdName, cmdArgs);
                    foreach (var e in await resultTask)
                    {
                        Server_TcpCommandResponseReceived(null, e);
                    }
                }
                else if (inpt.StartsWith("!"))
                {
                    var split   = inpt.TrimStart('!').Split(' ');
                    var cmdName = split[0];
                    var cmdArgs = split.Skip(1).ToArray();

                    ArdServer.SendTcpCommand(cmdName, cmdArgs, Server_TcpCommandResponseReceived, null);
                }
                else if (inpt.StartsWith("T!"))
                {
                    var split     = inpt.TrimStart('T').TrimStart('!').Split(' ');
                    var topicName = split[0];
                    var topicData = split.Skip(1).ToArray();

                    ArdServer.TopicManager.SendMessage(topicName, topicData[0]);
                }
                else if (inpt.ToLower() == "cls")
                {
                    Console.Clear();
                }
                else if (inpt.ToLower() == "exit")
                {
                    return;
                }
                else
                {
                    ArdServer.SendTcpMessage(inpt);
                }
            }
        }
예제 #3
0
 public void dependency_OnChange(object sender, SqlNotificationEventArgs e)
 {
     MsgHub.Show();
 }