private void ProcessPlayerLeave(byte[] msg, int currIndex)
        {
            currIndex += 1;
            StringBuilder s = new StringBuilder();

            while (msg[currIndex] != 0)
            {
                s.Append((char)msg[currIndex++]);
            }
            //Server sends a player left instruction to you when you leave a game
            //if the current game is null it means you have already left
            if (currGame != null)
            {
                var leftPlayer = users.GetUserFromName(s.ToString());

                currGame.users.RemoveUser(leftPlayer);

                if (leftPlayer.Category.Equals("Buddies"))
                {
                    KailleraTrayManager.Instance.handleTrayEvent(TrayFlags.PopValues.buddyLeftGame, leftPlayer);
                }

                GUIBundle playerLeftBundle = new GUIBundle();
                playerLeftBundle.Users   = new UserList(currGame.users);
                playerLeftBundle.gameNum = currGame.id;
                WindowMngr.updateWindow(playerLeftBundle);
            }
        }
        private void ProcessServerChat(byte[] msg, int currIndex)
        {
            currIndex++;
            StringBuilder s = new StringBuilder();

            //Get sender
            while (msg[currIndex] != 0)
            {
                s.Append((char)msg[currIndex++]);
            }
            string username = s.ToString();

            s.Clear();
            currIndex++;

            //Get text
            while (msg[currIndex] != 0)
            {
                s.Append(Encoding.UTF8.GetString(msg, currIndex++, 1));
            }
            string text = s.ToString();
            //Get user instances
            User user = users.GetUserFromName(username);

            GUIBundle bund = new GUIBundle();

            bund.ChatText         = text;
            bund.TargetUser       = users.GetUserFromName(username);
            bund.TargetUserString = username;
            WindowMngr.updateWindow(bund);
        }
        private void ProcessUserLeave(byte[] msg, int currIndex)
        {
            currIndex++;

            while (msg[currIndex++] != 0)
            {
                ;
            }
            int userID = BitConverter.ToInt16(msg, currIndex);

            var leftUser = users.GetUserFromID(userID);

            if (leftUser == null)
            {
                return;
            }

            if (leftUser.Category.Equals("Buddies"))
            {
                KailleraTrayManager.Instance.handleTrayEvent(TrayFlags.PopValues.buddyLeftServer, leftUser);
            }

            users.RemoveUser(leftUser);
            GUIBundle bund = new GUIBundle();

            bund.Users = new UserList(users);
            WindowMngr.updateWindow(bund);
        }
Exemple #4
0
 /// <summary>
 /// Updates the users window
 /// </summary>
 /// <param name="gb"></param>
 public void updateUsersWindow(GUIBundle gb)
 {
     if (usersWindow != null)
     {
         usersWindow.updateUsers(gb.Users.users);
     }
 }
        /// <summary>
        /// Handles the game chat and calls the window manager to update the window
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="currIndex"></param>
        private void ProcessGameChat(byte[] msg, int currIndex)
        {
            currIndex++;
            StringBuilder s = new StringBuilder();

            //Get sender
            while (msg[currIndex] != 0)
            {
                s.Append((char)msg[currIndex++]);
            }
            string username = s.ToString();

            s.Clear();
            currIndex++;

            //Get text
            while (msg[currIndex] != 0)
            {
                s.Append((char)msg[currIndex++]);
            }
            string text = s.ToString();
            //Get user instances
            User      user           = users.GetUserFromName(username);
            GUIBundle gameChatBundle = new GUIBundle();

            gameChatBundle.ChatText         = text;
            gameChatBundle.gameNum          = currGame.id;
            gameChatBundle.TargetUser       = user;
            gameChatBundle.TargetUserString = username;

            WindowMngr.updateWindow(gameChatBundle);
        }
 /// <summary>
 /// Updates the users window
 /// </summary>
 /// <param name="gb"></param>
 public void updateUsersWindow(GUIBundle gb)
 {
     if (usersWindow != null)
     {
         usersWindow.updateUsers(gb.Users.users);
     }
 }
        private void ProcessUserJoin(byte[] msg, int currIndex)
        {
            users.AddUser(User.ParseUserJoined(msg, currIndex));
            GUIBundle bund = new GUIBundle();

            bund.Users = users;

            WindowMngr.updateWindow(bund);
        }
        private void ParseLoginSuccess(byte[] msg, int currIndex)
        {
            LoginSuccess.parseUsersGames(msg, ref users, ref games, currIndex);

            GUIBundle bund = new GUIBundle();

            bund.Users = new UserList(users);
            gamesChanged(games);
            WindowMngr.updateWindow(bund);
        }
        private void ProcessUserJoin(byte[] msg, int currIndex)
        {
            var newUser = User.ParseUserJoined(msg, currIndex);

            if (newUser.Category.Equals("Buddies"))
            {
                KailleraTrayManager.Instance.handleTrayEvent(TrayFlags.PopValues.buddyJoinedServer, newUser);
            }

            users.AddUser(newUser);
            GUIBundle bund = new GUIBundle();

            bund.Users = new UserList(users);

            WindowMngr.updateWindow(bund);
        }
        private void ProcessUserLeave(byte[] msg, int currIndex)
        {
            currIndex++;

            while (msg[currIndex++] != 0)
            {
                ;
            }
            int userID = BitConverter.ToInt16(msg, currIndex);

            users.RemoveUser(users.GetUserFromID(userID));
            GUIBundle bund = new GUIBundle();

            bund.Users = users;
            WindowMngr.updateWindow(bund);
        }
        /// <summary>
        /// Parses the player join message and adds the user to the current game
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="currIndex"></param>
        private void ProcessPlayerJoin(byte[] msg, int currIndex)
        {
            currIndex += 2;
            int gameId = BitConverter.ToInt32(msg, currIndex);

            currIndex += 4;
            StringBuilder s = new StringBuilder();

            while (msg[currIndex] != 0)
            {
                s.Append((char)msg[currIndex++]);
            }

            currIndex++;

            int ping = BitConverter.ToInt32(msg, currIndex);

            currIndex += 4;
            int userID = BitConverter.ToInt16(msg, currIndex);

            currIndex += 2;
            byte connection = msg[currIndex];

            User newPlayer = users.GetUserFromID(userID);

            //This is bad!
            if (newPlayer == null)
            {
                return;
            }

            if (newPlayer.Category.Equals("Buddies"))
            {
                KailleraTrayManager.Instance.handleTrayEvent(TrayFlags.PopValues.buddyJoinedGame, newPlayer);
            }

            if (currGame != null)
            {
                currGame.users.AddUser(newPlayer);
            }
            GUIBundle playerJoinedBundle = new GUIBundle();

            playerJoinedBundle.Users   = new UserList(currGame.users);
            playerJoinedBundle.gameNum = currGame.id;
            WindowMngr.updateWindow(playerJoinedBundle);
        }
        /// <summary>
        /// Processes message of the day
        /// MOTD has string "server" first, so
        /// we will skip over it
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="currIndex"></param>
        private void ProcessMOTD(byte[] msg, int currIndex)
        {
            currIndex++;
            StringBuilder s = new StringBuilder();

            while (msg[currIndex++] != 0)
            {
                currIndex++;
            }
            while (msg[currIndex] != 0)
            {
                s.Append((char)msg[currIndex++]);
            }
            GUIBundle MOTDbund = new GUIBundle();

            MOTDbund.MOTDText = s.ToString();
            MOTDbund.gameNum  = 0;
            WindowMngr.updateWindow(MOTDbund);
        }
Exemple #13
0
        /// <summary>
        /// Dispatched version of join game success which can launch the new window
        /// </summary>
        /// <param name="game"></param>
        public void joinGameSuccessDispatched(Game game)
        {
            ChatViewModel gameChat = new ChatViewModel(game.id, this, game);

            gameChat.leaveGame   += mgr.leaveGame;
            gameChat.sendGameChat = sendGameChat;
            gameChat.leaveGame   += exitGame;

            //Weird error here
            ChatWindows.Add(gameChat);
            gameChat.addBuddyList += addToBuddyList;
            gameChat.wind.sendPM  += sendPM;

            //Create a new GUIBundle and update the game chat window with existing players
            GUIBundle newGameBund = new GUIBundle();

            newGameBund.gameNum = game.id;
            newGameBund.Users   = game.users;
            updateWindow(newGameBund);
            currGame = game;
        }
        /// <summary>
        /// Updates the chat window with a GUIBundle.  At this point there shouldn't
        /// be more than one window receiving the update, but maybe in the future there will be
        /// </summary>
        /// <param name="gb">The UI update - sent to corresponding window based on game number</param>
        public void updateWindow(GUIBundle gb)
        {
            
            int gamenumber = gb.gameNum;
            mutex.WaitOne();

            IEnumerable<ChatViewModel> targwind = from wind in ChatWindows where wind.gameNumber == gamenumber select wind;

            List<ChatViewModel> newList = new List<ChatViewModel>(targwind);
            mutex.ReleaseMutex();


                foreach (ChatViewModel c in newList)
                {
                    c.updater(gb);
                }


                if (gb.gameNum == MAINCHAT && gb.Users != null)
                {
                    System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => updateUsersWindow(gb)));
                }
        }
Exemple #15
0
        /// <summary>
        /// Updates the chat window with a GUIBundle.  At this point there shouldn't
        /// be more than one window receiving the update, but maybe in the future there will be
        /// </summary>
        /// <param name="gb">The UI update - sent to corresponding window based on game number</param>
        public void updateWindow(GUIBundle gb)
        {
            int gamenumber = gb.gameNum;

            mutex.WaitOne();

            IEnumerable <ChatViewModel> targwind = from wind in ChatWindows where wind.gameNumber == gamenumber select wind;

            List <ChatViewModel> newList = new List <ChatViewModel>(targwind);

            mutex.ReleaseMutex();


            foreach (ChatViewModel c in newList)
            {
                c.updater(gb);
            }


            if (gb.gameNum == MAINCHAT && gb.Users != null)
            {
                System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => updateUsersWindow(gb)));
            }
        }
        private void ProcessUserJoin(byte[] msg, int currIndex)
        {
            var newUser = User.ParseUserJoined(msg, currIndex);

            if (newUser.Category.Equals("Buddies"))
                KailleraTrayManager.Instance.handleTrayEvent(TrayFlags.PopValues.buddyJoinedServer, newUser);

            users.AddUser(newUser);
            GUIBundle bund = new GUIBundle();
            bund.Users = new UserList(users);

            WindowMngr.updateWindow(bund);
        }
        private void ProcessUserLeave(byte[] msg, int currIndex)
        {
            currIndex++;

            while (msg[currIndex++] != 0) ;
            int userID = BitConverter.ToInt16(msg, currIndex);

            var leftUser = users.GetUserFromID(userID);

            if (leftUser == null)
            {
                return;
            }

            if (leftUser.Category.Equals("Buddies"))
                KailleraTrayManager.Instance.handleTrayEvent(TrayFlags.PopValues.buddyLeftServer, leftUser);

            users.RemoveUser(leftUser);
            GUIBundle bund = new GUIBundle();
            bund.Users = new UserList(users);
            WindowMngr.updateWindow(bund);
        }
        /// <summary>
        /// Parses the player join message and adds the user to the current game
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="currIndex"></param>
        private void ProcessPlayerJoin(byte[] msg, int currIndex)
        {
            currIndex += 2;
            int gameId = BitConverter.ToInt32(msg, currIndex);
            currIndex += 4;
            StringBuilder s = new StringBuilder();
            while (msg[currIndex] != 0)
            {
                s.Append((char)msg[currIndex++]);
            }

            currIndex++;

            int ping = BitConverter.ToInt32(msg, currIndex);
            currIndex += 4;
            int userID = BitConverter.ToInt16(msg, currIndex);

            currIndex += 2;
            byte connection = msg[currIndex];

            User newPlayer = users.GetUserFromID(userID);

            //This is bad!
            if (newPlayer == null) return;

            if (newPlayer.Category.Equals("Buddies"))
            {
                KailleraTrayManager.Instance.handleTrayEvent(TrayFlags.PopValues.buddyJoinedGame, newPlayer);
            }

            if(currGame != null)
                currGame.users.AddUser(newPlayer);
            GUIBundle playerJoinedBundle = new GUIBundle();
            playerJoinedBundle.Users = new UserList(currGame.users);
            playerJoinedBundle.gameNum = currGame.id;
            WindowMngr.updateWindow(playerJoinedBundle);
        }
        private void ProcessPlayerLeave(byte[] msg, int currIndex)
        {
            currIndex+=1;
            StringBuilder s = new StringBuilder();
            while (msg[currIndex] != 0)
                s.Append((char)msg[currIndex++]);
            //Server sends a player left instruction to you when you leave a game
            //if the current game is null it means you have already left
            if (currGame != null)
            {
                var leftPlayer = users.GetUserFromName(s.ToString());

                currGame.users.RemoveUser(leftPlayer);

                if (leftPlayer.Category.Equals("Buddies"))
                {
                    KailleraTrayManager.Instance.handleTrayEvent(TrayFlags.PopValues.buddyLeftGame, leftPlayer);
                }

                GUIBundle playerLeftBundle = new GUIBundle();
                playerLeftBundle.Users = new UserList(currGame.users);
                playerLeftBundle.gameNum = currGame.id;
                WindowMngr.updateWindow(playerLeftBundle);
            }
        }
        private void ProcessServerChat(byte[] msg, int currIndex)
        {
            currIndex++;
            StringBuilder s = new StringBuilder();

            //Get sender
            while (msg[currIndex] != 0)
            {
                s.Append((char)msg[currIndex++]);
            }
            string username = s.ToString();
            s.Clear();
            currIndex++;

            //Get text
            while (msg[currIndex] != 0)
            {
                s.Append(Encoding.UTF8.GetString(msg, currIndex++, 1));
            }
            string text = s.ToString();
            //Get user instances
            User user = users.GetUserFromName(username);

            GUIBundle bund = new GUIBundle();
            bund.ChatText = text;
            bund.TargetUser = users.GetUserFromName(username);
            bund.TargetUserString = username;
            WindowMngr.updateWindow(bund);
        }
        private void ProcessUserLeave(byte[] msg, int currIndex)
        {
            currIndex++;

            while (msg[currIndex++] != 0) ;
            int userID = BitConverter.ToInt16(msg, currIndex);
            users.RemoveUser(users.GetUserFromID(userID));
            GUIBundle bund = new GUIBundle();
            bund.Users = users;
            WindowMngr.updateWindow(bund);
        }
        /// <summary>
        /// Updates the window - calls dispatcher so correct thread is invoked
        /// </summary>
        /// <param name="bundle"></param>
        public void WindowUpdate(GUIBundle bundle)
        {
            if (bundle.Users != null)
            {
                listBox1.Dispatcher.Invoke(Userup, bundle.Users.users);
            }
            if (bundle.ChatText != null)
            {
                Dispatcher.BeginInvoke((Action)(() =>
                {
                    //The message will not appear if ignored
                    if (SettingsManager.getMgr().isIgnored(bundle.TargetUserString))
                    {
                        return;
                    }


                    //Stupid text coloring!  Better way to do this using flow documents?

                    Random rand = new Random();

                    var dateText = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);

                    dateText.Text = "(" + DateTime.Now.ToShortTimeString() + ") ";

                    dateText.ApplyPropertyValue(TextElement.ForegroundProperty, ColorUtil.txtColors[0]);
                    dateText.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Normal);

                    TextRange username = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);

                    username.Text = bundle.TargetUserString;

                    var randColor = ColorUtil.txtColors[rand.Next(0, ColorUtil.txtColors.Count)];

                    username.ApplyPropertyValue(TextElement.ForegroundProperty, randColor);
                    username.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);

                    var chatText = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);

                    chatText.Text = ": " + bundle.ChatText + Environment.NewLine;

                    chatText.ApplyPropertyValue(TextElement.ForegroundProperty, ColorUtil.txtColors[0]);
                    chatText.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Normal);

                    Logger.logChat(bundle.TargetUserString + " - " + bundle.ChatText);

                    //We only want the textbox to autoscroll when the scrollbar is at the bottom, otherwise no autoscroll
                    //Code adopted from MSDN: http://social.msdn.microsoft.com/Forums/en-AU/wpf/thread/25a08bda-dc5e-4689-a6b0-7d4d78aff06b

                    //Get vertical scroll position
                    double dVer = richTextBox1.VerticalOffset;

                    //Get vertical size of scrollable content area
                    double dViewport = richTextBox1.ViewportHeight;

                    //Get vertical size of visible content area
                    double dExtent = richTextBox1.ExtentHeight;

                    if (dVer != 0)
                    {
                        if (dVer + dViewport == dExtent)
                        {
                            // richTextBox1.Focus();
                            richTextBox1.ScrollToEnd();
                            // textBox1.Focus();
                        }
                    }
                }
                                                ));
            }
            if (bundle.MOTDText != null)
            {
                Dispatcher.BeginInvoke((Action)(() => {
                    var motd = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);

                    motd.Text = "(" + DateTime.Now.ToShortTimeString() + ") " + bundle.MOTDText + Environment.NewLine;

                    motd.ApplyPropertyValue(TextElement.ForegroundProperty, ColorUtil.txtColors[0]);
                    motd.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);


                    //We only want the textbox to autoscroll when the scrollbar is at the bottom, otherwise no autoscroll
                    //Code adopted from MSDN: http://social.msdn.microsoft.com/Forums/en-AU/wpf/thread/25a08bda-dc5e-4689-a6b0-7d4d78aff06b

                    //Get vertical scroll position
                    double dVer = richTextBox1.VerticalOffset;

                    //Get vertical size of scrollable content area
                    double dViewport = richTextBox1.ViewportHeight;

                    //Get vertical size of visible content area
                    double dExtent = richTextBox1.ExtentHeight;

                    if (dVer != 0)
                    {
                        if (dVer + dViewport == dExtent)
                        {
                            //richTextBox1.Focus();
                            richTextBox1.ScrollToEnd();
                            //textBox1.Focus();
                        }
                    }
                }
                                                ));
            }
        }
        /// <summary>
        /// Updates the window - calls dispatcher so correct thread is invoked
        /// </summary>
        /// <param name="bundle"></param>
        public void WindowUpdate(GUIBundle bundle)
        {
            if (bundle.Users != null)
            {
                listBox1.Dispatcher.Invoke(Userup, bundle.Users.users);
            }
            if (bundle.ChatText != null)
            {

                Dispatcher.BeginInvoke((Action)(() => 
                {
                    //The message will not appear if ignored
                    if (SettingsManager.getMgr().isIgnored(bundle.TargetUserString)) return;


                    //Stupid text coloring!  Better way to do this using flow documents?

                    Random rand = new Random();

                    var dateText = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);
                    
                    dateText.Text = "(" + DateTime.Now.ToShortTimeString() + ") ";

                    dateText.ApplyPropertyValue(TextElement.ForegroundProperty, ColorUtil.txtColors[0]);
                    dateText.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Normal);

                    TextRange username = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);

                    username.Text = bundle.TargetUserString;

                    var randColor = ColorUtil.txtColors[rand.Next(0, ColorUtil.txtColors.Count)];

                    username.ApplyPropertyValue(TextElement.ForegroundProperty, randColor);
                    username.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);

                    var chatText = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);

                    chatText.Text = ": " + bundle.ChatText + Environment.NewLine; 

                    chatText.ApplyPropertyValue(TextElement.ForegroundProperty, ColorUtil.txtColors[0]);
                    chatText.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Normal);

                    Logger.logChat(bundle.TargetUserString + " - " + bundle.ChatText);

                    //We only want the textbox to autoscroll when the scrollbar is at the bottom, otherwise no autoscroll
                    //Code adopted from MSDN: http://social.msdn.microsoft.com/Forums/en-AU/wpf/thread/25a08bda-dc5e-4689-a6b0-7d4d78aff06b

                    //Get vertical scroll position
                    double dVer = richTextBox1.VerticalOffset;
                    
                    //Get vertical size of scrollable content area
                    double dViewport = richTextBox1.ViewportHeight;

                    //Get vertical size of visible content area
                    double dExtent = richTextBox1.ExtentHeight;

                    if (dVer != 0)
                    {
                        if (dVer + dViewport == dExtent)
                        {
                           // richTextBox1.Focus();
                            richTextBox1.ScrollToEnd();
                           // textBox1.Focus();
                        }
                    }




                }
                    ));
            }
            if (bundle.MOTDText != null)
            {
                Dispatcher.BeginInvoke((Action)(() => {

                    var motd = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);

                    motd.Text = "(" + DateTime.Now.ToShortTimeString() + ") " + bundle.MOTDText + Environment.NewLine;

                    motd.ApplyPropertyValue(TextElement.ForegroundProperty, ColorUtil.txtColors[0]);
                    motd.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);


                    //We only want the textbox to autoscroll when the scrollbar is at the bottom, otherwise no autoscroll
                    //Code adopted from MSDN: http://social.msdn.microsoft.com/Forums/en-AU/wpf/thread/25a08bda-dc5e-4689-a6b0-7d4d78aff06b

                    //Get vertical scroll position
                    double dVer = richTextBox1.VerticalOffset;
                    
                    //Get vertical size of scrollable content area
                    double dViewport = richTextBox1.ViewportHeight;

                    //Get vertical size of visible content area
                    double dExtent = richTextBox1.ExtentHeight;

                    if (dVer != 0)
                    {
                        if (dVer + dViewport == dExtent)
                        {
                                //richTextBox1.Focus();
                                richTextBox1.ScrollToEnd();
                                //textBox1.Focus();
                            
                        }
                    }
                }
                    ));
            }

        }
        private void ParseLoginSuccess(byte[] msg, int currIndex)
        {
            LoginSuccess.parseUsersGames(msg, ref users, ref games, currIndex);

            GUIBundle bund = new GUIBundle();
            bund.Users = new UserList(users);
            gamesChanged(games);
            WindowMngr.updateWindow(bund);
        }
        /// <summary>
        /// Dispatched version of join game success which can launch the new window
        /// </summary>
        /// <param name="game"></param>
        public void joinGameSuccessDispatched(Game game)
        {
            ChatViewModel gameChat = new ChatViewModel(game.id, this, game);
            gameChat.leaveGame += mgr.leaveGame;
            gameChat.sendGameChat = sendGameChat;
            gameChat.leaveGame += exitGame;

            //Weird error here
                ChatWindows.Add(gameChat);
            gameChat.addBuddyList += addToBuddyList;
            gameChat.wind.sendPM += sendPM;

            //Create a new GUIBundle and update the game chat window with existing players
            GUIBundle newGameBund = new GUIBundle();
            newGameBund.gameNum = game.id;
            newGameBund.Users = game.users;
            updateWindow(newGameBund);
            currGame = game;
        }
 /// <summary>
 /// Processes message of the day
 /// MOTD has string "server" first, so
 /// we will skip over it
 /// </summary>
 /// <param name="msg"></param>
 /// <param name="currIndex"></param>
 private void ProcessMOTD(byte[] msg, int currIndex)
 {
     currIndex++;
     StringBuilder s = new StringBuilder();
     while (msg[currIndex++] != 0)
     currIndex++;
     while (msg[currIndex] != 0)
         s.Append((char)msg[currIndex++]);
     GUIBundle MOTDbund = new GUIBundle();
     MOTDbund.MOTDText = s.ToString();
     MOTDbund.gameNum = 0;
     WindowMngr.updateWindow(MOTDbund);
     handlePM(s.ToString());
     
 }
        /// <summary>
        /// Handles the game chat and calls the window manager to update the window
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="currIndex"></param>
        private void ProcessGameChat(byte[] msg, int currIndex)
        {
            currIndex++;
            StringBuilder s = new StringBuilder();

            //Get sender
            while(msg[currIndex] != 0)
            {
                s.Append((char)msg[currIndex++]);
            }
            string username = s.ToString();
            s.Clear();
            currIndex++;

            //Get text
            while (msg[currIndex] != 0)
            {
                s.Append((char)msg[currIndex++]);
            }
            string text = s.ToString();
            //Get user instances
            User user = users.GetUserFromName(username);
            GUIBundle gameChatBundle = new GUIBundle();
            gameChatBundle.ChatText = text;
            gameChatBundle.gameNum = currGame.id;
            gameChatBundle.TargetUser = user;
            gameChatBundle.TargetUserString = username;

            WindowMngr.updateWindow(gameChatBundle);
        }
        private void ProcessUserJoin(byte[] msg, int currIndex)
        {
            users.AddUser(User.ParseUserJoined(msg, currIndex));
            GUIBundle bund = new GUIBundle();
            bund.Users = users;

            WindowMngr.updateWindow(bund);
        }