Example #1
0
        protected override void OnCommandReceived(ClientMessageEventArgs eventArgs)
        {
            base.OnCommandReceived(eventArgs);

            if (!(eventArgs.Client is ChatClient))
                return;

            ChatClient cc = (ChatClient)eventArgs.Client;
            if (cc.Name == null && eventArgs.Message.Name != "name")
                return;
            else if (cc.Name == null)
            {
                if (!Clients.Where(c => c is ChatClient).Cast<ChatClient>().Any(c => c.Name == eventArgs.Message.Parameters[0].ToString()))
                {
                    cc.Name = eventArgs.Message.Parameters[0].ToString();
                    cc.Send(new Command("nameOk", cc.Name));
                }
                else
                {
                    cc.Send(new Command("nameBad"));
                }
            }
            else if (eventArgs.Message.Name == "message" && !string.IsNullOrWhiteSpace((string)eventArgs.Message.Parameters[1]))
                foreach (var c in Clients)
                    c.Send(new Command("message", cc.Name, eventArgs.Message.Parameters[0], eventArgs.Message.Parameters[1]));
        }
 public static void Run(Game g, Player p, ClientMessageEventArgs e)
 {
     if (_messageMap.TryGetValue(e.MessageType, out ClientMessage msg))
     {
         msg.Run(g, p, e.MessageObject);
     }
 }
        private static void MinerCallBack_MsgSynSession(ClientMessageEventArgs e)
        {
            var synLoginItemList = new List <SynSessionItem>();
            var synLoginSession  = new MsgSynSessionMessage(synLoginItemList);

            SynServerLoginSession(synLoginSession);
        }
        private static void MinerCallBack_CmdSetClientName(ClientMessageEventArgs e)
        {
            var ClientName = e.Message["NewName"]?.ToString();

            setting = new Setting(ClientName);
            clientId.SetInfo("VpsClientId", ClientName);
            Tcp.Send(new RpNameModefiedMessage(ClientName, true));
        }
Example #5
0
 private void messageFromClient(object sender, ClientMessageEventArgs arg)
 {
     System.Console.WriteLine("Message From Client on Topic {0}", arg.TopicName);
     if (arg.TopicName == "ECHO")
     {
        theRemoteService.SendToClient(arg.ClientDetails.ClientId, arg.Message);
     }
 }
 public static void Exec(ClientMessageEventArgs e)
 {
     dic.TryGetValue(e.Title, out Action <ClientMessageEventArgs> action);
     if (action == null)
     {
         throw new ActionNotRegException($"命令[{e.Title}]未被注册");
     }
     else
     {
         action.Invoke(e);
     }
 }
        private static void MinerCallBack_CmdServerRunSchedule(ClientMessageEventArgs e)
        {
            var s = new Thread(() =>
            {
                var nextRuntimeStamp = Convert.ToInt32(e.Message["TaskStamp"]?.ToString());
                ServerBeginRun(nextRuntimeStamp);
            })
            {
                IsBackground = true
            };

            s.Start();
        }
 private static void Tcp_OnMessage(object sender, ClientMessageEventArgs e)
 {
     //Logger.SysLog(e.RawString, "通讯记录");
     try
     {
         Console.WriteLine($"来自服务器:{e.RawString}");
         MinerCallBack.Exec(e);
     }
     catch (ActionNotRegException ex)
     {
         Console.WriteLine($"读取数据发生异常:{ex.Message}\n{e.RawString}");
     }
 }
        private static void MinerCallBack_CmdSynInit(ClientMessageEventArgs e)
        {
            var interval        = e.Message["Interval"];
            var assumePriceRate = e.Message["AssumePriceRate"];

            if (interval == null || assumePriceRate == null)
            {
                Tcp.Send(new RpMsgInvalidMessage("synInit"));
                return;
            }
            InitSetting(Convert.ToInt32(interval), Convert.ToDouble(assumePriceRate));
            Program.vpsStatus = VpsStatus.Syning;
            Tcp.Send(new RpInitCompletedMessage());
        }
Example #10
0
        private void ReceiveMessage(object sender, ClientMessageEventArgs e)
        {
            try
            {
                this.Invoke((EventHandler) delegate
                {
                    this.Text = $"{ClientName}:{e.RawString}";
                    switch (e.Title)
                    {
                    case TcpMessageEnum.CmdCheckBillUrl:
                        {
                            //<newCheckBill><targetUrl>baidu.com</targetUrl><price>999</price><assumePrice>0</assumePrice></newCheckBill>
                            targetUrl      = e.Message["Url"].ToString();
                            price          = Convert.ToDouble(e.Message["Price"]);
                            assumePrice    = Convert.ToDouble(e.Message["AssumePrice"]);
                            string bidInfo = $"{price}/{assumePrice}";
                            ISPrice.Text   = bidInfo;
                            CheckNewCmd(CmdInfo.ShowWeb, targetUrl);

                            //switch (e.Message["Act"].ToString())
                            //{
                            //	case "0":
                            //		{
                            //			CheckNewCmd(CmdInfo.ShowWeb, targetUrl);
                            //			break;
                            //		}
                            //	case "1":
                            //		{
                            //			if (assumePrice > price)
                            //				CheckNewCmd(CmdInfo.SubmitBill, targetUrl);
                            //			else CheckNewCmd(CmdInfo.ShowWeb, targetUrl);
                            //			break;
                            //		}
                            //}

                            break;
                        }

                    case TcpMessageEnum.MsgSynSession:
                        SynLoginSession();
                        break;
                    }
                });
            }
            catch (Exception ex)
            {
                new Thread(() => { MessageBox.Show($"RecvMessage:{ex.Message}"); }).Start();
            }
        }
Example #11
0
 private void OnClientMessageReceived(object sender, ClientMessageEventArgs e)
 {
     //Event handler for message posted from socket client
     try {
         //Signal message processing required
         if (this.MessageReceived != null)
         {
             this.MessageReceived(this, e);
         }
     }
     catch (Exception ex) { if (this.Error != null)
                            {
                                this.Error(this, new ErrorEventArgs(ex));
                            }
     }
 }
        private static void MinerCallBack_MsgSynFileList(ClientMessageEventArgs e)
        {
            var rawList = e.Message["List"];
            var list    = new List <SynSingleFile>();

            foreach (var item in rawList)
            {
                list.Add(new SynSingleFile()
                {
                    Name    = item["Name"]?.ToString(),
                    Version = item["Version"]?.ToString()
                });
            }

            var synFileList = new MsgSynFileListMessage(list);

            SynFile(synFileList);
        }
Example #13
0
        private void leechClient_ClientMessage(object sender, ClientMessageEventArgs e)
        {
            Action a = () => this.txtStatus.Text = e.Message;

            this.txtStatus.Dispatcher.Invoke(a, DispatcherPriority.Normal);
        }
Example #14
0
        /// <summary>
        /// IPC Receive Messages Callback
        /// </summary>
        /// <param name="e">Message event args</param>
        private void ReadIpc(ClientMessageEventArgs e)
        {
            var msg = e.Message; //Get the message

            SendCommand?.Invoke(this, "ipc§" + "tut_client_proxy" + "§" + msg);
        }
Example #15
0
 /// <summary>
 /// Called when a client sends a message.
 /// </summary>
 /// <param name="sender">Object that triggered the event.</param>
 /// <param name="e">Event arguments.</param>
 public abstract void Received(object sender, ClientMessageEventArgs e);
Example #16
0
 private void ClientMessageHandler(object sender, ClientMessageEventArgs e)
 {
     myChatBox.AddMessage(e.Message);
 }
Example #17
0
 /// <summary>
 /// Used when the client receives a message.
 /// </summary>
 /// <param name="e">Event arguments containing the message that was received.</param>
 protected virtual void OnReceive(ClientMessageEventArgs e)
 {
     Received?.Invoke(this, e);
 }
 private static void MinerCallBack_CmdReRasdial(ClientMessageEventArgs e)
 {
     Tcp.Send(new RpReRasdialMessage("cmd"));
     RedialToInternet();
 }
 private static void MinerCallBack_CmdModefyTargetUrl(ClientMessageEventArgs e)
 {
     InnerTargetUrl = e.Message["NewUrl"]?.ToString();
 }
 private static void MinerCallBack_CmdTransferFile(ClientMessageEventArgs e)
 {
     TranslateFileStart();
 }
 private static void MinerCallBack_CmdServerRun(ClientMessageEventArgs e)
 {
     ServerResetConfig();
 }
 private void ShowErrorMessage(object sender, ClientMessageEventArgs e) => MessageBox.Show(e.Message, "Client Error", MessageBoxButton.OK, MessageBoxImage.Error);
 private static void MinerCallBack_CmdStartNewProgram(ClientMessageEventArgs e)
 {
     StartNewProgram();
 }
 private static void MinerCallBack_MsgHeartBeat(ClientMessageEventArgs e)
 {
     Console.WriteLine("服务器保持连接确认");
 }
 private static void MinerCallBack_CmdSubClose(ClientMessageEventArgs e)
 {
     Environment.Exit(0);
 }