예제 #1
0
        private static void CallbackAction_UserLeftRoom(object arg)
        {
            var user = (User)arg;

            mainWindow.Dispatcher.Invoke(() => gameState.RemoveUser(user));
            gameState.AddChatMessage(null, user.Name + " покидает комнату");
            LogSaver.Log("User left room");
        }
예제 #2
0
        private static void CallbackAction_UserJoinedRoom(object arg)
        {
            var user = (User)arg;

            mainWindow.Dispatcher.Invoke(() => gameState.AddUser(user));
            gameState.AddChatMessage(null, "В комнату заходит " + user.Name);
            LogSaver.Log("User entered room ");
        }
예제 #3
0
        private static void CallbackAction_StateChanged(object arg)
        {
            var state = (GameState.State)arg;

            mainWindow.Dispatcher.Invoke(() =>
            {
                gameState.State = state;
            });

            LogSaver.Log("State changed. New = " + gameState.State);
        }
예제 #4
0
        private static void CallbackAction_VarOfCurWordChanged(object arg)
        {
            var word = (string)arg;

            mainWindow.Dispatcher.Invoke(() =>
            {
                gameState.VarOfCurWord = word;
            });

            LogSaver.Log("VarOfCurWordChanged " + word);
        }
예제 #5
0
 // Process message
 public static void ChangeClientView(GameMessage message)
 {
     if (!CallbackActions.ContainsKey(message.actionType))
     {
         LogSaver.Log("Callback action for GameMessage.ActionType=" +
                      message.actionType.ToString() + " not implemented");
         throw new NotImplementedException("Callback action for GameMessage.ActionType=" +
                                           message.actionType.ToString() + " not implemented");
     }
     //Call appropriate function
     CallbackActions[message.actionType](message.actionAgrument);
 }
예제 #6
0
 public static async void Registration(string name, string password)
 {
     LogSaver.Log("Trying to registr");
     try
     {
         await proxy.RegistrationAsync(name, password);
     }
     catch (FaultException <GameException> e)
     {
         MessageBox.Show(e.Detail.Message);
     }
 }
예제 #7
0
        private static void CallbackAction_AddedRoom(object arg)
        {
            LogSaver.Log("NewRoomAdded");
            var  tuple = (Tuple <string, int>)arg;
            Room room  = new Room();

            room.Id   = tuple.Item2;
            room.Name = tuple.Item1;
            mainWindow.Dispatcher.Invoke(() =>
            {
                gameState.Rooms.Add(room);
            });
        }
예제 #8
0
        public static async void Login(string name, string password)
        {
            LogSaver.Log("Trying to login");
            try
            {
                gameState.Me = await proxy.LoginAsync(name, password);

                GotoLobby();
                mainWindow.IsEnabled = true;
                loginWindow.Close();
            }
            catch (FaultException <GameException> e)
            {
                MessageBox.Show(e.Detail.Message);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
예제 #9
0
 public void Notify(GameMessage msg)
 {
     LogSaver.Log("Callback invoked " + msg.actionType.ToString());
     ClientControll.ChangeClientView(msg);
 }