private void Server_MessageReceived(object sender, TextReceivedEventArgs e) { messageReceivedTextBox.AppendText(string.Format("From client: {0}, Message: {1}" , e.ClientWhoSentText , e.TextReceived , Environment.NewLine)); }
private void Client_TextReceived(object sender, TextReceivedEventArgs e) { var args = new ServerReceivedTextEventArgs(sender as Connection, e); TextReceived?.Invoke(this, args); OnTextReceived(args); }
void HandleTextReceived(object sender, TextReceivedEventArgs trea) { if (trea.TextReceived.Substring(0, trea.TextReceived.IndexOf('\0')) != "status_check") { txtConsole.AppendText(string.Format("{0} - Received from: {3}, {1}{2}", DateTime.Now, trea.TextReceived, Environment.NewLine, trea.ClientWhoSentText)); txtConsole.AppendText(Environment.NewLine); String TEKST_Z_ARDUINO = trea.TextReceived.Replace("\0", ""); } //EKSPERYMENT if (trea.TextReceived.IndexOf('\0') > 0) { string chuj = trea.TextReceived.Substring(0, trea.TextReceived.IndexOf('\0')); if (chuj == "status_check") { if (StatusCheckBox.Checked) { SendDataToClient("ok", true); } else { SendDataToClient("ok", false); } } } }
// Zdzarzenie Server Text Received private void HandleTextReceived(object sender, TextReceivedEventArgs e) { // Dodaj komunikat do listy otrzymanych wiadomości MessageRcvListBox.Items.Add(string.Format("{0} - Received from {1}: {2}", DateTime.Now.ToString("d"), e.ClientSender, e.TextReceived)); // Przesuń na koniec listy MessageRcvListBox.TopIndex = MessageRcvListBox.Items.Count - 1; }
protected virtual void OnRaiseTextReceivedEvent(TextReceivedEventArgs trea) { EventHandler<TextReceivedEventArgs> handler = RaiseTextReceivedEvent; if (handler != null) { handler(this, trea); } }
private static void HandleClientTextReceived(object sender, TextReceivedEventArgs e) { Console.WriteLine(string.Format( "{0} - Received: {1}{2}", DateTime.Now, e.Text, Environment.NewLine )); }
void HandleTextReceived(object sender, TextReceivedEventArgs trea) { txtConsole.AppendText( string.Format( "{0} - Received from {2}: {1}{3}", DateTime.Now, trea.TextReceived, trea.ClientWhoSentText, Environment.NewLine)); }
/// <summary> /// The event handler to process received data through COM-port or UDP communication. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments that contains received text.</param> private void OnTextReceived(object sender, TextReceivedEventArgs e) { if (this.InvokeRequired) { // Using this.Invoke causes deadlock when closing serial port, and BeginInvoke is good practice anyway. this.BeginInvoke(new EventHandler <TextReceivedEventArgs>(this.OnTextReceived), new object[] { sender, e }); return; } this.historyBox.AppendTextReceivedFromRobot(e.Text); }
private void HandleTextReceived(object sender, TextReceivedEventArgs trea) { Console.WriteLine( string.Format( "{0} - Received: {1}{2}", DateTime.Now, trea.TextReceived, Environment.NewLine)); tbConsole.Text += $"{DateTime.Now} - Received text: {trea.TextReceived}{Environment.NewLine}"; }
private static void HandleTextReceived(object sender, TextReceivedEventArgs trea) { string msg = string.Format( "{0} - Received: {1}{2}", DateTime.Now, trea.TextReceived, Environment.NewLine); //Console.WriteLine(msg); self.DisplayAlert("Transmission", msg, "OK"); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Publish specific ESP data to the predefined topics using Mqtt/QoS 1. </summary> /// /// <remarks> Jordi Hutjens, 26-10-2018. </remarks> /// /// <param name="e"> Containing the filtered received Mqtt text. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// private void PublishData(TextReceivedEventArgs e) { try { mqttClient.Publish("wekit/vest/GSR_Raw", Encoding.UTF8.GetBytes(e.GSR), MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, true); mqttClient.Publish("wekit/vest/Pulse_Raw", Encoding.UTF8.GetBytes(e.Pulse), MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, true); mqttClient.Publish("wekit/vest/Sht0_Temp", Encoding.UTF8.GetBytes(e.TempExternal), MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, true); mqttClient.Publish("wekit/vest/Sht0_Hum", Encoding.UTF8.GetBytes(e.HumExternal), MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, true); mqttClient.Publish("wekit/vest/Sht1_Temp", Encoding.UTF8.GetBytes(e.TempInternal), MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, true); mqttClient.Publish("wekit/vest/Sht1_Hum", Encoding.UTF8.GetBytes(e.HumInternal), MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, true); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private static void HandleTextReceived(object sender, TextReceivedEventArgs trea) { string msg = string.Format( "{0} - Received: {1}{2}", DateTime.Now, trea.TextReceived, Environment.NewLine); //Console.WriteLine(msg); if (trea.TextReceived.Contains("PONG")) { Toast.MakeText(self, "still connected...", ToastLength.Short).Show(); } else { Toast.MakeText(self, msg, ToastLength.Short).Show(); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Sends the published sensor data to the Learning Hub. </summary> /// /// <remarks> Jordi Hutjens, 26-10-2018. </remarks> /// /// <param name="e"> Parameter containing the filtered Json string data. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// public void SendDataToLH(TextReceivedEventArgs e) { var values = new List <string> { e.ESPTimeStamp, e.IMU1_AccX, e.IMU1_AccY, e.IMU1_AccZ, e.IMU1_GyroX, e.IMU1_GyroY, e.IMU1_GyroZ, e.IMU1_MagX, e.IMU1_MagY, e.IMU1_MagZ, e.IMU1_Q0, e.IMU1_Q1, e.IMU1_Q2, e.IMU1_Q3, e.IMU2_AccX, e.IMU2_AccY, e.IMU2_AccZ, e.IMU2_GyroX, e.IMU2_GyroY, e.IMU2_GyroZ, e.IMU2_MagX, e.IMU2_MagY, e.IMU2_MagZ, e.IMU2_Q0, e.IMU2_Q1, e.IMU2_Q2, e.IMU2_Q3, e.TempExternal, e.HumExternal, e.TempInternal, e.HumInternal, e.Pulse, e.GSR }; HubConnector.SendData(values); }
void HandleTextReceived(object sender, TextReceivedEventArgs trea) { if (trea.TextReceived != "????????????????????????????????????????????????????????????????") { if (trea.TextReceived.Contains("|")) { //checkedListBox1.Items.Insert(0, string.Format("{0} --- {1}",DateTime.Now, trea.TextReceived,trea.ClientWhoSentText)); string[] incomingMsg = trea.TextReceived.Split('|'); switch (incomingMsg[0]) { case "ANNOUNCE": listView1.Items.Insert(0, incomingMsg[1]); listView1.Items[0].Group = listView1.Groups[0]; ListViewItem.ListViewSubItem sbItem1 = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem sbItem2 = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem sbItem3 = new ListViewItem.ListViewSubItem(); sbItem1.Text = incomingMsg[2]; listView1.Items[0].SubItems.Insert(1, sbItem1); sbItem2.Text = incomingMsg[3]; listView1.Items[0].SubItems.Insert(2, sbItem2); sbItem3.Text = incomingMsg[4]; listView1.Items[0].SubItems.Insert(3, sbItem3); break; case "CLEANSERVED": for (int i = 0; i < listView1.Items.Count; i++) { int ii = 1; if (listView1.Items[i].Group == listView1.Groups[1]) { listView1.Items[i].Remove(); } ii++; } break; } } } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Updates the values. </summary> /// /// <remarks> Jordi Hutjens, 30-10-2018. </remarks> //////////////////////////////////////////////////////////////////////////////////////////////////// private void UpdateValues() { if (!Globals.JsonErrorThrown) { try { TextReceivedEventArgs args = new TextReceivedEventArgs { TextReceived = receivedStrMsg, ESPTimeStamp = jsonpar.ParsedUdpMsg.time, IMU1_AccX = jsonpar.ParsedUdpMsg.imus[0].ax, IMU1_AccY = jsonpar.ParsedUdpMsg.imus[0].ay, IMU1_AccZ = jsonpar.ParsedUdpMsg.imus[0].az, IMU1_GyroX = jsonpar.ParsedUdpMsg.imus[0].gx, IMU1_GyroY = jsonpar.ParsedUdpMsg.imus[0].gy, IMU1_GyroZ = jsonpar.ParsedUdpMsg.imus[0].gz, IMU1_MagX = jsonpar.ParsedUdpMsg.imus[0].mx, IMU1_MagY = jsonpar.ParsedUdpMsg.imus[0].my, IMU1_MagZ = jsonpar.ParsedUdpMsg.imus[0].mz, IMU1_Q0 = jsonpar.ParsedUdpMsg.imus[0].q0, IMU1_Q1 = jsonpar.ParsedUdpMsg.imus[0].q1, IMU1_Q2 = jsonpar.ParsedUdpMsg.imus[0].q2, IMU1_Q3 = jsonpar.ParsedUdpMsg.imus[0].q3, IMU2_AccX = jsonpar.ParsedUdpMsg.imus[1].ax, IMU2_AccY = jsonpar.ParsedUdpMsg.imus[1].ay, IMU2_AccZ = jsonpar.ParsedUdpMsg.imus[1].az, IMU2_GyroX = jsonpar.ParsedUdpMsg.imus[1].gx, IMU2_GyroY = jsonpar.ParsedUdpMsg.imus[1].gy, IMU2_GyroZ = jsonpar.ParsedUdpMsg.imus[1].gz, IMU2_MagX = jsonpar.ParsedUdpMsg.imus[1].mx, IMU2_MagY = jsonpar.ParsedUdpMsg.imus[1].my, IMU2_MagZ = jsonpar.ParsedUdpMsg.imus[1].mz, IMU2_Q0 = jsonpar.ParsedUdpMsg.imus[1].q0, IMU2_Q1 = jsonpar.ParsedUdpMsg.imus[1].q1, IMU2_Q2 = jsonpar.ParsedUdpMsg.imus[1].q2, IMU2_Q3 = jsonpar.ParsedUdpMsg.imus[1].q3, TempExternal = jsonpar.ParsedUdpMsg.shts[0].temp, HumExternal = jsonpar.ParsedUdpMsg.shts[0].hum, TempInternal = jsonpar.ParsedUdpMsg.shts[1].temp, HumInternal = jsonpar.ParsedUdpMsg.shts[1].hum, Pulse = jsonpar.ParsedUdpMsg.pulse, GSR = jsonpar.ParsedUdpMsg.gsr }; OnNewTextReceived(args); if (CheckParameters.Instance.LHRunning) { sendlh.SendDataToLH(args); } } catch (Exception ex) { TextReceivedEventArgs args = new TextReceivedEventArgs { TextReceived = ex.Message }; OnNewTextReceived(args); } } else { TextReceivedEventArgs args = new TextReceivedEventArgs { TextReceived = jsonpar.ParsedUdpMsg }; OnNewTextReceived(args); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Raising the event in the UdpManager class. </summary> /// /// <remarks> Jordi Hutjens, 26-10-2018. </remarks> /// /// <param name="e"> Containing the filtered Json string. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// protected virtual void OnNewTextReceived(TextReceivedEventArgs e) { NewUdpTextReceived?.Invoke(this, e); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Method to update the GUI textbox. </summary> /// /// <remarks> Jordi Hutjens, 26-10-2018. </remarks> /// /// <param name="sender"> MqttManager raising the event< </param> /// <param name="e"> Parameter containing the filtered Json string data. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// private void IUpdateTextBox(object sender, TextReceivedEventArgs e) { TextReceived = e.TextReceived; }
private static void HandleTextReceived(object sender, TextReceivedEventArgs textReceivedEventArgs) { Console.WriteLine(Environment.NewLine); Console.WriteLine($"{DateTime.Now} - Received: {textReceivedEventArgs.ClientWhoSentText}, {textReceivedEventArgs.TextReceived}"); }
protected virtual void OnTextReceived(TextReceivedEventArgs e) { TextReceived.Invoke(this, e); }
void HandleTextReceived(object sender, TextReceivedEventArgs trea) { txtConsole.AppendText(trea.TextReceived + Environment.NewLine); txtConsole.AppendText(System.Environment.NewLine); WyslijDoArduino(trea.TextReceived); }
void HandleTextReceived(object sender, TextReceivedEventArgs e) { textConsole.AppendText(Environment.NewLine); textConsole.AppendText($"{DateTime.Now} Received from {e.ClientWhoSentText}: {e.TextReceived}"); }
static void LogStdErr(object sender, TextReceivedEventArgs data) { LogCapturedOutput("stderr", sender, data.Text); }
private void HandleTextReceived(object sender, TextReceivedEventArgs e) { MessageRcvListBox.Items.Add(string.Format("{0} - {1} sent: {2}", DateTime.Now, e.ClientSender, e.TextReceived)); }
private static void HandleTextReceived(Object sender, TextReceivedEventArgs trea) { Console.WriteLine(string.Format("{0} - Received: {1}{2}", DateTime.Now, trea.TextReceived, Environment.NewLine)); }
void HandleServerTextReceived(object sender, TextReceivedEventArgs e) { txtConsole.AppendText(string.Format("{0} - Client: {1} Message:{2}{3}", DateTime.Now, e.Client, e.Text, Environment.NewLine)); }
private void TermConnector_TextReceivedEvent(object sender, TextReceivedEventArgs e) { textRx.Text += e.TextReceived; }
public ServerReceivedTextEventArgs(Connection source, TextReceivedEventArgs args) { _source = source; _text = args.Text; }
private static void HandleTextReceived(object sender, TextReceivedEventArgs trea) { //Console.WriteLine(trea.TextReceived); }