예제 #1
0
 public ChatEndpoint(string s)
 {
     loadEndpointPair(ChatEndpoint.decodeEndpointAddress(s));
     hexCode  = s;
     lastSeen = DateTime.Now;
     online   = true;
 }
예제 #2
0
        //whisper function
        private void sendChatMessage(ChatEndpoint target)
        {
            string whisper = Microsoft.VisualBasic.Interaction.InputBox("Please enter your message", "Whisper");

            if (whisper != null && whisper != "")
            {
                string msg = "" +
                             cm.self.hexCode + ":" +
                             WebUtility.UrlEncode(Properties.Settings.Default.Name) + ":" +
                             MulticonMgr.genTick() + ":" +
                             Properties.Settings.Default.Color + ":" +
                             WebUtility.UrlEncode(whisper) + ":Whisper;";
                target.MsgStack.Add(new ChatMessage(msg));
            }
        }
예제 #3
0
 public MulticonMgr(int inP, int outP)
 {
     inClient  = new UdpClient(new IPEndPoint(IPAddress.Any, inP));
     outClient = new UdpClient(new IPEndPoint(IPAddress.Any, outP));
     self      = new ChatEndpoint(getEndpoint(inClient), getEndpoint(outClient));
 }
예제 #4
0
// END SEND MESSAGE



// LISTENING LOOP FUNCTION
        private void listenLoop()
        {
            while (listenSwitch)
            {
                string msg = "";
                if (Properties.Settings.Default.Secret != "")
                {
                    byte[] key = Convert.FromBase64String(Properties.Settings.Default.Secret.Split(':')[0]);
                    byte[] iv  = Convert.FromBase64String(Properties.Settings.Default.Secret.Split(':')[1]);
                    Packet p   = cm.receiveBytes(cm.inClient);
                    string ep  = ChatEndpoint.encodeEndpointAddress((new IPEndPoint(p.sender.Address, 0)), p.sender);
                    ep = ep.Substring(0, 8) + "...." + ep.Substring(12, 4);
                    foreach (string n in cm.neighbours.Keys)
                    {
                        if (System.Text.RegularExpressions.Regex.Match(n, ep).Success)
                        {
                            cm.neighbours[n].lastSeen = DateTime.Now;
                        }
                    }
                    msg = MulticonMgr.DecryptStringFromBytes(p.bytes, key, iv);
                }
                else
                {
                    Packet p = cm.receiveBytes(cm.inClient);
                    msg = Encoding.ASCII.GetString(p.bytes);
                    string ep = ChatEndpoint.encodeEndpointAddress((new IPEndPoint(p.sender.Address, 0)), p.sender);
                    ep = ep.Substring(0, 8) + "...." + ep.Substring(12, 4);
                    foreach (string n in cm.neighbours.Keys)
                    {
                        if (System.Text.RegularExpressions.Regex.Match(n, ep).Success)
                        {
                            cm.neighbours[n].lastSeen = DateTime.Now;
                        }
                    }
                }

                this.msgHistory = msg + "\r\n" + this.msgHistory;
                switch (msg.Substring(0, 2))
                {
                case "S:":
                {
                    lock (this)
                    {
                        foreach (string m in msg.Substring(2, msg.Length - 2).Split(';'))
                        {
                            if (m.Length > 0)
                            {
                                PacketStack.Add(new ChatMessage(m));
                            }
                        }
                        break;
                    }
                }

                case "R:":
                {
                    lock (this)
                    {
                        cm.neighbours[msg.Split(':')[1]].ReceivedStack.Add(new ChatReceipt(msg.Substring(2, msg.Length - 2)));
                        break;
                    }
                }

                case "!:":
                {
                    lock (this)
                    {
                        PacketStack.Insert(0, msg);
                        break;
                    }
                }
                }
            }
        }
예제 #5
0
 public LVUserItem(ChatEndpoint ce)
 {
     relatedEndpoint = ce;
     base.Text       = ce.ToString();
     base.ForeColor  = (relatedEndpoint.online ? System.Drawing.Color.Black : System.Drawing.Color.DarkGray);
 }