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"); }
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 "); }
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); }
private static void CallbackAction_VarOfCurWordChanged(object arg) { var word = (string)arg; mainWindow.Dispatcher.Invoke(() => { gameState.VarOfCurWord = word; }); LogSaver.Log("VarOfCurWordChanged " + word); }
// 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); }
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); } }
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); }); }
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); } }
public void Notify(GameMessage msg) { LogSaver.Log("Callback invoked " + msg.actionType.ToString()); ClientControll.ChangeClientView(msg); }