Esempio n. 1
0
 private void AddNode(Client c)
 {
     tv_userlist.BeginUpdate();
     c.tn = new TreeNode(c.Username);
     tv_userlist.Nodes.Add(c.tn);
     tv_userlist.EndUpdate();
 }
Esempio n. 2
0
        private static void OnChatPaket(object sender, PacketEventArgs e)
        {
            switch (e.pak.ContainerID)
            {
                case SEND_MESSAGE.ContID:
                    Debug.WriteLine("SEND_MESSAGE Packet");
                    if (SendM1.UnpackContainer(e.pak, OPTIONS.Chat))
                    {
                        Message msg = new Message();

                        msg.command = 10; // message

                        msg.UserID = SendM1.UserID;
                        msg.Messagedata = SendM1.Message;

                        msg.Username = msg.UserID.ToString();

                        try
                        {
                            msg.Username = ClientArray[msg.UserID].Username;
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex.ToString());
                        }

                        IncommingChat.Enqueue(msg);
                    }
                    break;
                case SEND_USER.ContID:
                    Debug.WriteLine("SEND_USER Packet");
                    if (SendU1.UnpackContainer(e.pak, OPTIONS.Chat))
                    {
                        int statID = SendU1.StatusID;
                        if (statID == STATUS.USER_NEW)
                        {
                            uint ID = SendU1.UserID;
                            string Username = SendU1.Username;

                            Client c = new Client();
                            c.Username = Username;
                            c.ID = ID;

                            ClientArray[ID] = c;

                            Message msg = new Message();

                            msg.command = 11; // new

                            msg.cli = c;
                            msg.UserID = SendU1.UserID;
                            msg.Username = SendU1.Username;

                            msg.Messagedata = "new client '" + c.Username + "' connected.";

                            IncommingChat.Enqueue(msg);
                            Debug.WriteLine("New User: "******" ID: " + c.ID);
                        }

                        if (statID == STATUS.USER_DISCONNECT)
                        {
                            uint ID = SendU1.UserID;

                            try
                            {
                                Client c = ClientArray[ID];

                                Message msg = new Message();

                                msg.command = 12; // Delete

                                msg.Messagedata = "Client '" + c.Username + "' disconnected.";

                                msg.cli = c;

                                IncommingChat.Enqueue(msg);
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine(ex.ToString());
                            }
                        }

                    }
                    break;
            }
        }
Esempio n. 3
0
 private void RemoveNode(Client c)
 {
     tv_userlist.BeginUpdate();
     tv_userlist.Nodes.Remove(c.tn);
     tv_userlist.EndUpdate();
 }