Пример #1
0
 public void ReceiveMessage(Message M)
 {
     txtConversation.Text += M.From + ": " + M.Content + '\n';
     txtConversation.CaretIndex = txtConversation.Text.Length;
     txtConversation.ScrollToEnd();
     txtMessage.Focus();
 }
Пример #2
0
 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();
 }
Пример #3
0
        /// <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();
        }
Пример #4
0
        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();
            }
        }
Пример #5
0
        // 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);
 }
Пример #7
0
 // 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));
     }
 }
Пример #8
0
 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);
            }
        }
Пример #10
0
 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");
 }