示例#1
0
        private Dictionary<UserInfo, long> userTimeouts; // for removing expired users

        #endregion Fields

        #region Constructors

        public LobbyForm(Lobby lobby)
        {
            InitializeComponent();

            this.lobby = lobby;
            this.userGames = new Dictionary<UserInfo, ICollection<String>>();
            this.nicknameTextBox.Text = Options.nickname;
            this.currentUser = new UserInfo(Options.nickname);
            this.lobby.OnMessageReveived += lobby_OnMessageReveived;

            // GUI Config
            tabPageAll = new ChatTabPage("Broadcast");
            tabPageAll.Text = "All:";
            this.tabControlChat.TabPages.Add(tabPageAll);

            this.messageTextBox.KeyDown += new KeyEventHandler(delegate(object o, KeyEventArgs e) {
                if (e.KeyCode == Keys.Enter)
                {
                    sendMessageButton.PerformClick();
                }
            });

            this.gamesListBox.ContextMenu = new ContextMenu();
            this.gamesListBox.ContextMenu.MenuItems.Add(0, new MenuItem("Join Game Channel", delegate(object o, EventArgs e)
            {
                ChatTabPage t = joinChannel(this.gamesListBox.SelectedItem.ToString());
                t.Select();
            }));

            /******************************************************************************************
             * Check every second for expiring users
             *****************************************************************************************/
            /*
            this.expiringTimer = new Timer();
            this.expiringTimer.Interval = Options.EXPIRING_INTERVAL_CHECK;
            this.expiringTimer.Tick += delegate(object o, EventArgs e)
            {
                userTimeouts.
                foreach(KeyValuePair<UserInfo, long> k in userTimeouts)
                {
                    if (k.Value > CurrentMillis.Millis)
                    {
                        userTimeouts.
                    }
                }
            };
            this.expiringTimer.Start();
             */
        }
示例#2
0
 public ChatMessage(UserInfo user, String text)
 {
     this.User = user;
     this.Text = text;
 }
示例#3
0
        private void updateChannelUsers(string chanelNo5, UserInfo userInfo)
        {
            // Search Channel in all Tabs (there's no index for the channels)
            foreach (ChatTabPage t in tabControlChat.TabPages)
            {
                if (t.Channel == chanelNo5) // Ha! We found it!
                {
                    // search for existing username in channel
                    bool userInChannel = false;
                    foreach (UserInfo i in t.Users)
                    {
                        if (i.Name == userInfo.Name)
                        {
                            userInChannel = true;
                            break;
                        }
                    }

                    // If the user is NOT listed already, we add him
                    if (!userInChannel)
                    {
                        t.Users.Add(userInfo);
                        tabControlChat.Invoke(new MethodInvoker(delegate() {
                            if (t == tabControlChat.SelectedTab)
                            {
                                channelUsersListBox.Items.Add(userInfo);
                            }
                        }));
                        break;
                    }
                }
            }
        }
 public AnnouncementMessage(UserInfo user, ICollection<String> gameNames)
 {
     this.User = user;
     this.GameNames = gameNames;
 }