コード例 #1
0
ファイル: ChatWindow.cs プロジェクト: read-0nly/FreeChat
// Proc
        private void processReceivedSendcode(ChatMessage p)
        {
            ChatReceipt receipt = new ChatReceipt(cm.self.hexCode, p.owner, p.tickCode);
            if (!(cm.neighbours[p.ownerHex].nickname == p.owner))
            {
                cm.neighbours[p.ownerHex].nickname = p.owner;
                object[] bucket = new object[listBox1.Items.Count];
                listBox1.Items.CopyTo(bucket,0);
                listBox1.Items.Clear();
                listBox1.Items.AddRange(bucket);
            }
            
            // adviseReceived

            if (Properties.Settings.Default.Secret != "")
            {
                string message = ("R:" + receipt);
                byte[] key = Convert.FromBase64String(Properties.Settings.Default.Secret.Split(':')[0]);
                byte[] iv = Convert.FromBase64String(Properties.Settings.Default.Secret.Split(':')[1]);
                byte[] msgB = MulticonMgr.EncryptStringToBytes(message, key, iv);
                MulticonMgr.sendBytes(msgB, cm.neighbours[p.ownerHex].InPoint, cm.outClient);
            }
            else
            {
                MulticonMgr.sendString(
                    ("R:" + receipt),
                    cm.neighbours[p.ownerHex].InPoint, cm.outClient);
            }
            //identify duplicates and add and rotate.
            bool isDup = false;
            foreach (ChatMessage histMsg in ConvoStack)
            {
                if (histMsg.tickCode == p.tickCode)
                {
                    if (histMsg.owner == p.owner)
                    {
                        isDup = true;
                    }
                }
            }
            if (!isDup)
            {
                if (ConvoStack.Count > (Properties.Settings.Default.ChatHistory))
                {
                    ConvoStack.RemoveAt(0);
                }
                ConvoStack.Add(p);
            }
        }
コード例 #2
0
ファイル: ChatWindow.cs プロジェクト: read-0nly/FreeChat
// END LISTENING LOOP



// PROCESS FUNCTIONS
        private void processReceivedSendcode(string p)
        {

            //split packed messages and handle
            string[] msgArray = p.Substring(2, p.Length - 2).Split(';');
            foreach (string msg in msgArray)
            {
                ChatMessage msgMsg = new ChatMessage(msg);
                cm.neighbours[msgMsg.ownerHex].nickname = msgMsg.owner;
                ChatReceipt receipt = new ChatReceipt(cm.self.hexCode, msgMsg.owner, msgMsg.tickCode);
                bool isDup = false;
                // adviseReceived

                if (Properties.Settings.Default.Secret != "")
                {
                    string message = ("R:" + receipt);
                    byte[] key = Convert.FromBase64String(Properties.Settings.Default.Secret.Split(':')[0]);
                    byte[] iv = Convert.FromBase64String(Properties.Settings.Default.Secret.Split(':')[1]);
                    byte[] msgB = MulticonMgr.EncryptStringToBytes(message, key, iv);
                    MulticonMgr.sendBytes(msgB, cm.neighbours[msgMsg.ownerHex].InPoint, cm.outClient);
                }
                else
                {
                    MulticonMgr.sendString(
                        ("R:" + receipt),
                        cm.neighbours[msgMsg.ownerHex].InPoint, cm.outClient);
                }
                //identify duplicates and add and rotate.
                foreach (ChatMessage histMsg in ConvoStack)
                {
                    if (histMsg.tickCode == msgMsg.tickCode)
                    {
                        if (histMsg.owner == msgMsg.owner)
                        {
                            isDup = true;
                        }
                    }
                }
                if (!isDup)
                {
                    if (ConvoStack.Count > (Properties.Settings.Default.ChatHistory))
                    {
                        ConvoStack.RemoveAt(0);
                    }
                    ConvoStack.Add(msgMsg);
                }

            }
        }