Пример #1
0
        private void Server_DataReceived(object sender, SimpleTCP.Message e)
        {
            //Update mesage to txtStatus
            conS.Invoke((MethodInvoker) delegate()
            {
                conS.Text += e.MessageString;
                e.ReplyLine(STARTTHING.Text + das + hhmmssSHOW.Text + String.Format("{0:00000}", Convert.ToInt32(dai[0])) + String.Format("{0:00000}", Convert.ToInt32(dai[1])) + String.Format("{0:00000}", Convert.ToInt32(dai[2])) + String.Format("{0:00000}", Convert.ToInt32(dai[3])) + EndTHING.Text);
                for (int i = 0; i < 4; i++)
                {
                    switch (i)
                    {
                    case 0:
                        dai[i] = 0;
                        break;

                    case 1:
                        dai[i] = 0;
                        break;

                    case 2:
                        dai[i] = 0;
                        break;

                    case 3:
                        dai[i] = 0;
                        break;

                    default:
                        break;
                    }
                }
                das = "NP";
            });
        }
Пример #2
0
        /// <summary>
        /// ///////////////////////////////////////////////

        private void Client_DataReceived_work(object sender, SimpleTCP.Message e)   // working
        {
            void p()
            {
                String[] requirements = e.MessageString.Split((char)0x13);
                int      i            = 0;
                int      offset       = checkedListBox1.Items.Count; // function will be called several times



                while (i < requirements.Length)
                {
                    if (requirements[i] != "(none)" && requirements[i] != "" && requirements[i] != " ")
                    {
                        checkedListBox1.Items.Insert(i + offset, requirements[i]);
                    }
                    else
                    {
                        break;
                    }
                    i++;
                }
            };

            if (current_command == (int)command.GET_REQUIREMENTS)
            {
                checkedListBox1.Invoke((MethodInvoker)p);
            }
        }  // work
Пример #3
0
        private void Server_DataReceived(object sender, SimpleTCP.Message e)
        {
            /*textBox3.Invoke((MethodInvoker)delegate () {
             *   textBox3.Text += e.MessageString;
             *  e.Reply(string.Format("You said: {0}" ,  e.MessageString));
             * }
             * );*/

            //Корень сервера

            textBox3.Invoke((MethodInvoker) delegate() {
                textBox3.Text    += e.MessageString;
                string g          = e.MessageString;
                g                 = g.Substring(0, g.Length - 1);
                string gh         = "", d = "";
                DirectoryInfo dir = new DirectoryInfo(g);
                foreach (var item in dir.GetDirectories())
                {
                    gh += item.Name + " ";
                    foreach (var it in item.GetDirectories())
                    {
                        d += it.Name + "";
                    }
                }


                e.Reply(string.Format(gh + d, e.MessageString));
            }
                            );
        }
Пример #4
0
 private void Server_DataReceived(object sender, SimpleTCP.Message e)
 {
     txtStatus.Invoke((MethodInvoker) delegate() {
         txtStatus.Text += e.MessageString;
         e.ReplyLine(string.Format("You said : {0}", e.MessageString));
     });
 }
        static void Server_DataReceived(object sender, SimpleTCP.Message m)
        {
            Console.WriteLine(m.MessageString);                                   //Write message to console.
            string replyMessage = String.Format("You said {0}", m.MessageString); //This is the reply message

            m.ReplyLine(replyMessage);                                            //Send reply message back to client.
        }
Пример #6
0
 private void Client_DataReceived(object sender, SimpleTCP.Message e)
 {
     FileWorker.LogHelper.WriteLog("刷卡信息:" + e.MessageString);
     string[] messageArr = e.MessageString.Split(new string[] { "TRDS" }, StringSplitOptions.RemoveEmptyEntries);
     for (int j = 0; j < messageArr.Length; j++)
     {
         messageArr[j] = "TRDS" + messageArr[j];
     }
     for (int i = 0; i < messageArr.Length; i++)
     {
         string[] receMessage = messageArr[i].Split(new char[] { '|' });
         if (receMessage[0] == "TRDS")
         {
             if (receMessage.Length >= 10)
             {
                 AccessEntity accessEnt = AccessParseTool.parseAccess(receMessage);
                 string       jsonMess  = accessEnt.toJson();
                 KafkaWorker.sendAccessMessage(jsonMess);
                 anoAlarm = GetConfigMess();
                 if (anoAlarm.Keys.Contains(receMessage[9]))
                 {
                     AlarmEntity alarmEnt  = AlarmParseTool.parseAlarm(receMessage, anoAlarm);
                     string      jsonAlarm = alarmEnt.toJson();
                     KafkaWorker.sendAlarmMessage(jsonAlarm);
                 }
             }
             else
             {
                 FileWorker.LogHelper.WriteLog("刷卡信息不全," + messageArr[i]);
             }
         }
     }
 }
Пример #7
0
 private void Client_DataReceived(object sender, SimpleTCP.Message e)
 {
     txtStatus.Dispatcher.Invoke((Action) delegate()
     {
         txtStatus.Text += e.MessageString;
     });
 }
Пример #8
0
 //If data is received from the client
 private void Server_DataReceived(object sender, SimpleTCP.Message e)
 {
     StatusText.Invoke((MethodInvoker) delegate()
     {
         StatusText.Text += e.MessageString;
     });
 }
 private void _CLIENT_DataReceived(object sender, SimpleTCP.Message e)
 {
     sentMessagesBox.Invoke((MethodInvoker) delegate()
     {
         sentMessagesBox.Text += e.MessageString;
     });
 }
Пример #10
0
        public void Client_DataReceived(object sender, SimpleTCP.Message e)
        {
            Char delimiter = ';';

            String[] substrings = e.MessageString.Split(delimiter);

            Console.WriteLine("serwer odpowiedzial: " + e.MessageString);
            if (substrings[0] == "DHSK")
            {
                diffieHellman.SetIV(substrings[1]);
                diffieHellman.CreateDeriveKey(substrings[2].Replace("!", string.Empty));
                Login.serverIP      = this.serverIP;
                Login.diffieHellman = this.diffieHellman;
                Login log = new Login();
                if (InvokeRequired)
                {
                    Invoke(new Action(() =>
                    {
                        this.Hide();

                        log.ShowDialog();
                    }));
                }
                else
                {
                    this.Hide();

                    log.ShowDialog();
                }
            }
        }
Пример #11
0
 private void Client_DataReceived(object sender, SimpleTCP.Message e)
 {
     Invoke((MethodInvoker) delegate
     {
         tbPackagetime.Text    = DateTime.UtcNow.ToString();
         string[] val          = e.MessageString.Split(',');
         string temp           = val[2] + val[3];
         dateTime              = DateTime.ParseExact(temp, "ddMMyyyyHHmmss", CultureInfo.InvariantCulture);
         tbMeasurmentTime.Text = dateTime.ToString();
         tbTideHeight.Text     = val[4];
         tbRecive.AppendText(DateTime.Now.ToString() + " " + e.MessageString);
         tmConnection.Stop();
         tmConnection.Start();
         if (pbConnect.Maximum != 60)
         {
             pbConnect.Maximum = 60;
         }
         pbConnect.Value = 0;
         pbConnect.Refresh();
         using (DBConnector dbConnector = new DBConnector())
         {
             DBConnector.DbFilePath = Folderpath;
             dbConnector.Write(dateTime.ToString("s"), float.Parse(val[4]));
         }
     });
 }
Пример #12
0
        private void Client_DataReceived(object sender, SimpleTCP.Message e)
        {
            if (e.MessageString.Contains("command"))
            {
                JObject json = JObject.Parse(e.MessageString);

                string command = json["command"].ToString();

                switch (command)
                {
                case "DISABLEMESSAGING":
                    REASON = json["reason"].ToString();
                    mainWindow.ReceivedDisableMessaging();

                    break;

                case "NEWCHAT":
                    ulong RequesterID = ulong.Parse(json["requesterid"].ToString());

                    break;

                case "ENABLEMESSAGING":
                    mainWindow.ReceivedEnableMessaging();
                    break;
                }
            }
        }
Пример #13
0
        private void Server_DataReceived(object sender, SimpleTCP.Message e)
        {
            MsgLog(e.MessageString);
            var receiverList = e.MessageString.Replace("\u0013", "");
            var type         = receiverList.Split(',');

            switch (type[0])
            {
            case "Init":
                Iniciar();
                break;

            case "chute":
                ProcessaChute(type);
                break;

            case "palavra":
                ProcessaPalavra(type);
                break;

            default:
                MsgLog("Erro:" + e.MessageString);
                break;
            }
        }
Пример #14
0
        private void Client_DataReceived(object sender, SimpleTCP.Message e)
        {
            string msg = e.MessageString;

            string gotmsgregex = "ˇ|//msg///";

            string msgregex = msg.Remove(msg.Length - 1);

            if (Regex.IsMatch(msgregex, gotmsgregex))
            {
                msgregex = msgregex.Replace("ˇ|//msg///", "");
                String[] StringSeperators = new String[] { @"\\\|:|///" };
                String[] parameters       = msgregex.Split(StringSeperators, StringSplitOptions.None);
                ColoredConsole.ColoredWrite("\n" + parameters[0] + ": ", ConsoleColor.DarkYellow);

                Console.Write(parameters[1]);
                Console.WriteLine();
                if (ClientMode == 1)
                {
                    ColoredConsole.ColoredWrite("Message: ", ConsoleColor.Cyan);
                    WritedMessage = true;
                }
            }
            else
            {
                Console.WriteLine(msgregex);
            }
        }
Пример #15
0
        private void Server_DataReceived(object sender, SimpleTCP.Message e)
        {
            ConnectClient(portE);
            String response = logic.ServerJob(e);

            this.activeMessage.ReplyLine(response);
        }
Пример #16
0
        // Recebe dados do servidor
        private void Client_DataReceived(object sender, SimpleTCP.Message e)
        {
            var list = e.MessageString.Split(',');
            var type = list[0];

            switch (type)
            {
            case "Init":
            case "chute":
                IniciarJogo(list);
                break;

            case "pontos":
                ExibirPontos(list);
                break;

            case "puntuacao":
                ExibirPuntuacao(list);
                break;

            case "palavra":
                ExibirPalavra(list);
                break;

            case "msg":
                ExibirMsg(list);
                break;

            default:
                break;
            }
        }
Пример #17
0
 private void Client_DataReceived(object sender, SimpleTCP.Message e)
 {
     txtStatus.Invoke((MethodInvoker) delegate()
     {
         txtStatus.Text += e.MessageString;
     });
 }
Пример #18
0
        private void server_DataReceived(object sender, SimpleTCP.Message e)
        {
            TxtReceived.Invoke((MethodInvoker) delegate()
            {
                TxtReceived.Text += e.MessageString;
            });
            //DateTime dt = new DateTime();
            //dt = GetLifetimeService;
            string Time = Convert.ToString(GetLifetimeService());
            string Name = "";

            for (int i = 0; e.MessageString[i] != '-'; i++)
            {
                Name = Name.Insert(Name.Length, Convert.ToString(e.MessageString[i]));
            }
            string giatri = "";

            for (int j = e.MessageString.IndexOf('-') + 1; e.MessageString[j] != '\r'; j++)
            {
                giatri = giatri.Insert(giatri.Length, Convert.ToString(e.MessageString[j]));
            }
            dataGridViewAd2.Invoke((MethodInvoker) delegate()
            {
                dataGridViewAd2.AllowUserToAddRows = false;
                dataGridViewAd2.Rows.Add(Time, Name, giatri, "Chi tiết", "Xác nhận", "Hủy");
            });
            MessageBox.Show("Có yêu cầu mới");
        }
Пример #19
0
        private void GetClient(object sender, SimpleTCP.Message e)
        {
            string recieved = Regex.Replace(e.MessageString, @"\u0013", String.Empty);

            if (firstTime)
            {
                string[] coords = recieved.Split(',');

                Point p = new Point(int.Parse(coords[0]), int.Parse(coords[1]));

                f = new Food(Color.Black, Color.White, g, s, p);

                firstTime = false;
            }

            if (true)
            {
                string[]     ps = recieved.Split('|');
                List <Point> ls = new List <Point>();
                foreach (string p in ps)
                {
                    string[] coords = p.Split(',');
                    ls.Add(new Point(int.Parse(coords[0]), int.Parse(coords[1])));
                }
                s1.Position = ls;
                client.WriteLine(Compress(s.Position));
            }

            sketch.Invalidate();
        }
Пример #20
0
 private void Server_SenderDraw(object sender, SimpleTCP.Message DrawMsg)
 {
     txtStatusServer.Invoke((MethodInvoker) delegate()
     {
         txtStatusServer.Text += DrawMsg.MessageString;
     });
 }
Пример #21
0
 private void Client_DataRecieved(object sender, SimpleTCP.Message e)
 {
     txtRecievedData.Dispatcher.Invoke(delegate()
     {
         txtRecievedData.Text += e.MessageString;
     });
 }
Пример #22
0
 private void Server_DataReceived(object sender, SimpleTCP.Message e)
 {
     if (SetResult(FormingOrder(e.MessageString), _Orders))
     {
         Load?.Invoke(_Orders);
     }
 }
Пример #23
0
 private void Client_DataResived(object sender, SimpleTCP.Message e)
 {
     textBox3.Invoke((MethodInvoker) delegate()
     {
         textBox4.Text += e.MessageString;
     });
 }
Пример #24
0
 private void Server_DataReceived(object sender, SimpleTCP.Message e)
 {
     textStatus.Invoke((MethodInvoker) delegate()
     {
         if (e.MessageString.Contains("#N#A#M#E#"))
         {
             clientName = e.MessageString.Split(' ')[1];
             server.BroadcastLine("#N#A#M#E# " + serverName + ":");
         }
         else
         {
             if (!e.MessageString.Contains("Connected") && !e.MessageString.Contains("Connection terminated by Client"))
             {
                 textStatus.Text += clientName;
             }
             textStatus.Text += e.MessageString + System.Environment.NewLine;
             if (e.MessageString.Contains("Connection terminated by Client"))
             {
                 textStatus.Text += "Server starting..." + System.Environment.NewLine;
             }
         }
         if (e.MessageString.Contains("Connected"))
         {
             textStatus.Text += "Connected" + System.Environment.NewLine;
         }
     });
 }
Пример #25
0
        public void BittimiKontrol(SimpleTCP.Message e)
        {
            if (e.MessageString.Contains("Kazandı"))
            {
                button1.Invoke((MethodInvoker) delegate()
                {
                    button1.Text = "";
                });

                button2.Invoke((MethodInvoker) delegate()
                {
                    button2.Text = "";
                });

                button3.Invoke((MethodInvoker) delegate()
                {
                    button3.Text = "";
                });

                button4.Invoke((MethodInvoker) delegate()
                {
                    button4.Text = "";
                });

                button5.Invoke((MethodInvoker) delegate()
                {
                    button5.Text = "";
                });

                button6.Invoke((MethodInvoker) delegate()
                {
                    button6.Text = "";
                });

                button7.Invoke((MethodInvoker) delegate()
                {
                    button7.Text = "";
                });

                button8.Invoke((MethodInvoker) delegate()
                {
                    button8.Text = "";
                });

                button9.Invoke((MethodInvoker) delegate()
                {
                    button9.Text = "";
                });

                client.Disconnect();
                baglan_button.Invoke((MethodInvoker) delegate(){
                    baglan_button.Enabled = true;
                });
            }
            else
            {
                SiraKimde(e);
            }
        }
Пример #26
0
 private void Server_DataReceived(object sender, SimpleTCP.Message e)
 {
     if (SetResult(e.MessageString, Added, _Orders))
     {
         Status?.Invoke(e.MessageString.Replace("\u00a0", "").Replace(" ", ""));
         Load?.Invoke(_Orders);
     }
 }
Пример #27
0
 private void Client_DataReceived(object sender, SimpleTCP.Message e)
 {
     BittimiKontrol(e);
     ciktilar.Invoke((MethodInvoker) delegate()
     {
         ciktilar.Text += e.MessageString;
     });
 }
Пример #28
0
 private void ServerOnDataReceived(object sender, Message e)
 {
     txtStatus.Invoke((MethodInvoker) delegate
     {
         txtStatus.Text += e.MessageString;
         e.ReplyLine($"You said: {e.MessageString}");
     });
 }
Пример #29
0
 private void Client_DataReceived(object sender, SimpleTCP.Message e)
 {
     txtDisplay.Invoke((MethodInvoker) delegate()
     {
         txtDisplay.Text += e.MessageString;
         //  e.ReplyLine(string.Format("You said: {0}", e.MessageString));
     });
 }
Пример #30
0
 private void ServerDataReceived(object sender, SimpleTCP.Message e)
 {
     txtStatus.Invoke((MethodInvoker) delegate()
     {
         txtStatus.Text += Environment.NewLine + e.MessageString;
         e.ReplyLine(string.Format("You said: {0}{1}", e.MessageString, Environment.NewLine));
     });
 }
Пример #31
0
 private void NotifyEndTransmissionRx(TcpClient client, byte[] msg)
 {
     if (DataReceived != null)
     {
         Message m = new Message(msg, client, StringEncoder, Delimiter, AutoTrimStrings);
         DataReceived(this, m);
     }
 }
Пример #32
0
 internal void NotifyEndTransmissionRx(Server.ServerListener listener, TcpClient client, byte[] msg)
 {
     if (DataReceived != null)
     {
         Message m = new Message(msg, client, StringEncoder, Delimiter, AutoTrimStrings);
         DataReceived(this, m);
     }
 }