public void ReceiveMessage(Message M) { txtConversation.Text += M.From + ": " + M.Content + '\n'; txtConversation.CaretIndex = txtConversation.Text.Length; txtConversation.ScrollToEnd(); txtMessage.Focus(); }
private void SendMessage() { Message M = new Message(client.LocalClientInfo.Name, Name, txtMessage.Text); client.SendMessageUDP(M, RemoteEP); txtConversation.Text += client.LocalClientInfo.Name + ": " + txtMessage.Text + '\n'; txtMessage.Text = string.Empty; txtConversation.CaretIndex = txtConversation.Text.Length; txtConversation.ScrollToEnd(); txtMessage.Focus(); }
/// <summary> /// Ask the server for updated users list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Timer_Elapsed(object sender, ElapsedEventArgs e) { IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(Properties.Settings.Default.serverAddress), Properties.Settings.Default.port); Client.Start(endPoint); Shared.Message m = new Shared.Message(); m.sender = IPAddress.Parse(Properties.Settings.Default.ipv6); m.token = Properties.Settings.Default.token; m.command = Command.Users; Client.Send(m); Client.Receive(); }
private void sendBtn_Click(object sender, RoutedEventArgs e) { if (messageTxt.Text != "" && messageTxt.Text != " ") { AddMessage(messageTxt.Text, Message.MessageOwner.YOU); IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(Properties.Settings.Default.serverAddress), Properties.Settings.Default.port); Client.Start(endPoint); var m = new Shared.Message(); m.command = Command.Message; m.sender = IPAddress.Parse(Properties.Settings.Default.ipv6); m.content = messageTxt.Text; m.token = Properties.Settings.Default.token; Client.Send(m); messageTxt.Text = ""; Client.Receive(); } }
// Try to send a message to the Server public bool Send(Message Msg) { try { lock (Inner) // Thread safe Msg.Serialise(Out); } catch { return false; } return true; }
public void QueueMessage(Message message) { lock (_messages) _messages.Add(message); }
// Send a message to a single client public void Send(Message m) { try { lock (Connection) // Thread safe { if (Connected) m.Serialise(Out); // Serialise the message out } } catch { // If the send failed, treat it as a disconnect Disconnect(this, new DisconnectMessage(DisconnectType.Unexpected)); } }
public Message Create(Message msg) { msg.ID += 1; return msg; }
private async Task sendConfirmationMessage() { try { string dataBuffer = "{\"lightState\": \"On\"}"; Message eventMessage = new Message(Encoding.UTF8.GetBytes(dataBuffer)); eventMessage.To = Config.Default.PartnerDevice; await deviceClient.SendEventAsync(eventMessage); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
public MessageReceivedEventArgs(ClientInfo _clientInfo, Message _message, IPEndPoint _establishedEP) { clientInfo = _clientInfo; message = _message; EstablishedEP = _establishedEP; }
private async Task sendToTree(EmotionResult emotion) { var emotionJson = Newtonsoft.Json.JsonConvert.SerializeObject(emotion); Message m = new Message(Encoding.UTF8.GetBytes(emotionJson)); m.To = Config.Default.PartnerDevice; Log("Sending to tree"); await deviceClient.SendEventAsync(m); Log("Message sent"); }