Beispiel #1
0
        private void LobbyClientOnDataReceviedCaller(object sender, DataRecType type, object data)
        {
            //    Dispatcher.Invoke(new Action(() => this.LobbyClientOnOnDataReceived(sender, type, data)));

            //}
            //private void LobbyClientOnOnDataReceived(object sender, DataRecType type, object data)
            //{
            try
            {
                if (type == DataRecType.HostedGameReady)
                {
                    var port = data as Int32?;
                    if (port == null)
                    {
                        throw new Exception("Could not start game.");
                    }
                    var game = this.Game;
                    Program.LobbyClient.CurrentHostedGamePort = (int)port;
                    Program.GameSettings.UseTwoSidedTable     = true;
                    Program.Game   = new Game(GameDef.FromO8G(game.FullPath), Program.LobbyClient.Me.UserName);
                    Program.IsHost = true;

                    var hostAddress = Dns.GetHostAddresses(Program.GameServerPath).First();

                    Program.Client = new Client(hostAddress, (int)port);
                    Program.Client.Connect();
                    SuccessfulHost = true;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }
        }
Beispiel #2
0
 void LobbyClient_OnDataReceived(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.GameList || type == DataRecType.GamesNeedRefresh)
     {
         //RefreshGameList(null,null);
     }
 }
Beispiel #3
0
 void LobbyClient_OnDataReceived(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.GameInvite)
     {
         if (Program.IsGameRunning)
         {
             return;
         }
         var idata = data as InviteToGame;
         Task.Factory.StartNew(() =>
         {
             var hostedgame = new ApiClient().GetGameList().FirstOrDefault(x => x.Id == idata.SessionId);
             var endTime    = DateTime.Now.AddSeconds(15);
             while (hostedgame == null && DateTime.Now < endTime)
             {
                 hostedgame = new ApiClient().GetGameList().FirstOrDefault(x => x.Id == idata.SessionId);
             }
             if (hostedgame == null)
             {
                 Log.WarnFormat(
                     "Tried to read game invite from {0}, but there was no matching running game", idata.From.UserName);
                 return;
             }
             var game = GameManager.Get().GetById(hostedgame.GameId);
             if (game == null)
             {
                 throw new UserMessageException("Game is not installed.");
             }
             WindowManager.GrowlWindow.AddNotification(new GameInviteNotification(idata, hostedgame, game));
         });
     }
 }
Beispiel #4
0
 private void LobbyClientOnOnDataRecieved(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.FriendList)
     {
         RefreshList();
     }
 }
Beispiel #5
0
 private void LobbyClientOnDataReceived(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.FriendList)
     {
         //this.InvokeFriendList();
     }
 }
Beispiel #6
0
 private void LobbyClientOnOnDataRecieved(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.FriendList)
     {
         RefreshList();
     }
 }
Beispiel #7
0
        private void LobbyClientOnDataReceviedCaller(object sender, DataRecType type, object data)
        {
            try
            {
                if (type == DataRecType.HostedGameReady)
                {
                    var gameData = data as HostedGameData;
                    if (gameData == null)
                    {
                        throw new Exception("Could not start game.");
                    }
                    var game = this.Game;
                    Program.LobbyClient.CurrentHostedGamePort = (int)gameData.Port;
                    //Program.GameSettings.UseTwoSidedTable = true;
                    Program.GameEngine    = new GameEngine(game, Program.LobbyClient.Me.UserName, false, this.Password);
                    Program.IsHost        = true;
                    Program.IsMatchmaking = false;

                    var hostAddress = Dns.GetHostAddresses(AppConfig.GameServerPath).First();

                    // Should use gameData.IpAddress sometime.
                    Program.Client = new ClientSocket(hostAddress, (int)gameData.Port);
                    Program.Client.Connect();
                    SuccessfulHost = true;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }
        }
Beispiel #8
0
 void LobbyClient_OnDataReceived(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.GameList || type == DataRecType.GamesNeedRefresh)
     {
         Log.Info("Games List Received");
         RefreshGameList();
     }
 }
Beispiel #9
0
 void LobbyClient_OnDataReceived(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.GameList || type == DataRecType.GamesNeedRefresh)
     {
         RefreshGameList();
         IsRefreshingGameList = false;
     }
 }
Beispiel #10
0
 private void LobbyClientOnOnDataReceived(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.UserSubChanged)
     {
         needsRefresh = true;
         //InvokeResetUserList();
     }
 }
Beispiel #11
0
 void LobbyClient_OnDataReceived(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.GameList || type == DataRecType.GamesNeedRefresh)
     {
         Trace.WriteLine("Games Received");
         RefreshGameList();
         waitingForGames = false;
     }
 }
Beispiel #12
0
 private void LobbyClientOnOnDataReceived(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.UserSubChanged)
     {
         var d = data as User;
         if (d == null)
         {
             return;
         }
         if (d.Equals(_user))
         {
             OnPropertyChanged("IsSub");
         }
     }
 }
Beispiel #13
0
 void lobbyClient_OnDataRecieved(DataRecType type, object e)
 {
     if (type == DataRecType.ServerMessage)
     {
         string m = e as string;
         if (m != null && !String.IsNullOrWhiteSpace(m))
         {
             MessageBox.Show(m,"Server Message",MessageBoxButton.OK,MessageBoxImage.Information);
         }
     }
 }
Beispiel #14
0
        private void LobbyClientOnDataReceviedCaller(object sender, DataRecType type, object data)
        {
            //    Dispatcher.Invoke(new Action(() => this.LobbyClientOnOnDataReceived(sender, type, data)));

            //}
            //private void LobbyClientOnOnDataReceived(object sender, DataRecType type, object data)
            //{
            try
            {
                if (type == DataRecType.HostedGameReady)
                {
                    var port = data as Int32?;
                    if (port == null)
                        throw new Exception("Could not start game.");
                    var game = this.Game;
                    Program.LobbyClient.CurrentHostedGamePort = (int)port;
                    Program.GameSettings.UseTwoSidedTable = true;
                    Program.GameEngine = new GameEngine(game,Program.LobbyClient.Me.UserName);
                    Program.IsHost = true;

                    var hostAddress = Dns.GetHostAddresses(AppConfig.GameServerPath).First();

                    Program.Client = new Client(hostAddress, (int)port);
                    Program.Client.Connect();
                    SuccessfulHost = true;
                }

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }
        }
Beispiel #15
0
        private void LobbyClientOnOnDataRecieved(object sender ,DataRecType type , object data)
        {
            if(type ==DataRecType.GameList)
                ReloadGameList();
            else if (type ==DataRecType.GamesNeedRefresh)
            {
                Dispatcher.Invoke(new Action(() =>
                    {
                    bRefreshing.Visibility = Visibility.Visible;
                    Program.LobbyClient.BeginGetGameList();
                    }));

            }
        }
Beispiel #16
0
        void LobbyClient_OnDataReceived(object sender, DataRecType type, object data)
        {
            if (type == DataRecType.GameList || type == DataRecType.GamesNeedRefresh)
            {

                Log.Info("Games List Received");
                RefreshGameList();
            }
        }
Beispiel #17
0
 void LobbyClient_OnDataReceived(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.GameInvite)
     {
         if (Program.IsGameRunning) return;
         var idata = data as InviteToGame;
         Task.Factory.StartNew(() =>
         {
             var hostedgame = new ApiClient().GetGameList().FirstOrDefault(x => x.Id == idata.SessionId);
             var endTime = DateTime.Now.AddSeconds(15);
             while (hostedgame == null && DateTime.Now < endTime)
             {
                 hostedgame = new ApiClient().GetGameList().FirstOrDefault(x => x.Id == idata.SessionId);
             }
             if (hostedgame == null)
             {
                 Log.WarnFormat(
                     "Tried to read game invite from {0}, but there was no matching running game", idata.From.UserName);
                 return;
             }
             var game = GameManager.Get().GetById(hostedgame.GameId);
             if (game == null)
             {
                 throw new UserMessageException("Game is not installed.");
             }
             WindowManager.GrowlWindow.AddNotification(new GameInviteNotification(idata, hostedgame, game));
         });
     }
 }
Beispiel #18
0
 private void LobbyClientOnOnDataReceived(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.UserSubChanged)
     {
         needsRefresh = true;
         //InvokeResetUserList();
     }
 }
Beispiel #19
0
        void LobbyClient_OnDataReceived(object sender, DataRecType type, object data)
        {
            if (type == DataRecType.GameList || type == DataRecType.GamesNeedRefresh)
            {

                //RefreshGameList(null,null);
            }
        }
        private void LobbyClientOnDataReceviedCaller(object sender, DataRecType type, object data)
        {
            try
            {
                if (type == DataRecType.HostedGameReady)
                {
                    var gameData = data as HostedGameData;
                    if (gameData == null)
                        throw new Exception("Could not start game.");
                    var game = this.Game;
                    Program.LobbyClient.CurrentHostedGamePort = (int)gameData.Port;
                    //Program.GameSettings.UseTwoSidedTable = true;
                    Program.GameEngine = new GameEngine(game,Program.LobbyClient.Me.UserName,false,this.Password);
                    Program.IsHost = true;
                    Program.IsMatchmaking = false;

                    var hostAddress = Dns.GetHostAddresses(AppConfig.GameServerPath).First();

					// Should use gameData.IpAddress sometime.
                    Program.Client = new ClientSocket(hostAddress, (int)gameData.Port);
                    Program.Client.Connect();
                    SuccessfulHost = true;
                }

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }

        }
Beispiel #21
0
 void LobbyClient_OnDataReceived(object sender, DataRecType type, object data)
 {
     if (type == DataRecType.GameList || type == DataRecType.GamesNeedRefresh)
     {
         Trace.WriteLine("Games Received");
         RefreshGameList();
         waitingForGames = false;
     }
 }
Beispiel #22
0
 private void lobbyClient_OnDataRecieved(DataRecType type, object e)
 {
     if(type == DataRecType.FriendList)
     {
         RefreshList();
     }
 }