public Game(string gid, User testSpheroP1, User testDroneP2, int state, int status, int time, int hit, string opn) { this.SpheroPlayer = testSpheroP1; this.DronePlayer = testDroneP2; this.GameStatus = status; this.OpponentName = opn; this.GameState = state; this.MaxTime = time; this.MaxHits = hit; this.GameId = gid; }
private async void StartingGame(Game g, User u) { // Ready and waiting for other user if (g.GameStatus == 3 && u.UserName == App.Current.AppUser.UserName) { } var messageDialog = new MessageDialog("Do you want to Join the Game now?"); // Add commands and set their command ids messageDialog.Commands.Add(new UICommand("Not Now", (command) => { App.Current.CurrentGame = null; }, 0)); messageDialog.Commands.Add(new UICommand("Join Game", (command) => { App.Current.SignalRHub.JoinGame(App.Current.AppUser, App.Current.CurrentGame); App.Current.SignalRHub.SignalRServerNotification -= new SignalRServerHandler(SignalRHub_SignalRServerNotification); Frame.Navigate(typeof(LobbyPage)); }, 1)); // Set the command that will be invoked by default messageDialog.DefaultCommandIndex = 1; // Show the message dialog and get the event that was invoked via the async operator var commandChosen = await messageDialog.ShowAsync(); /* //chatDialog.Text += "\r\n" + "Starting Game..."; //Was the App User the last one to Join? If yes trigger Start Event if (u.UserName == App.Current.AppUser.UserName) { App.Current.SignalRHub.JoinGame(App.Current.AppUser, App.Current.CurrentGame); App.Current.SignalRHub.SignalRServerNotification -= new SignalRServerHandler(SignalRHub_SignalRServerNotification); Frame.Navigate(typeof(LobbyPage)); //App.Current.SignalRHub.StartGame(App.Current.CurrentGame, u); //Lobby Message to start game } // Add commands and set their command ids //Set the command that will be invoked by default //messageDialog.DefaultCommandIndex = 1; //Show the message dialog and get the event that was invoked via the async operator //await messageDialog.ShowAsync(); */ }
public async virtual void UserLogin(User tabletChatClient) { // Fire up SignalR Connection & join chatroom. try { await gameConnection.Start(); if (gameConnection.State == Microsoft.AspNet.SignalR.Client.ConnectionState.Connected) { await SignalRGameHub.Invoke("Login", tabletChatClient); } } catch (Exception ex) { // Do some error handling. Could not connect to Sever Error. Debug.WriteLine("Error: "+ ex.Message); } // On // Listen to chat events on SignalR Server & wire them up appropriately. SignalRGameHub.On<User, ServerMessage>("addNewUpdate", (user, message) => { SignalREventArgs userArgs = new SignalREventArgs(); userArgs.UserUpdate = user; userArgs.CustomServerMessage = message; // Raise custom event & let it bubble up. SignalRServerNotification(this, userArgs); }); SignalRGameHub.On<string, string>("addNewMessageToPage", (message, word) => { SignalREventArgs chatArgs = new SignalREventArgs(); chatArgs.ChatMessageFromServer = message; chatArgs.ChatMessageFromServer = word; // Raise custom event & let it bubble up. SignalRServerNotification(this, chatArgs); }); SignalRGameHub.On<User, List<Game>, List<User>, ServerMessage>("update", (user, agl, ul, sm) => { SignalREventArgs uArgs = new SignalREventArgs(); uArgs.UserUpdate = user; uArgs.CustomGameList = agl; uArgs.CustomAvailableOpponents = ul; uArgs.CustomServerMessage = sm; // Raise custom event & let it bubble up. SignalRServerNotification(this, uArgs); }); SignalRGameHub.On<Game, ServerMessage>("gameCreated", (g, sm) => { SignalREventArgs gArgs = new SignalREventArgs(); gArgs.CustomGameObject = g; gArgs.CustomServerMessage = sm; // Raise custom event & let it bubble up. SignalRServerNotification(this, gArgs); }); SignalRGameHub.On<User, Game, ServerMessage>("lobbyMessage", (u, g, sm) => { SignalREventArgs gArgs = new SignalREventArgs(); gArgs.UserUpdate = u; gArgs.CustomGameObject = g; gArgs.CustomServerMessage = sm; // Raise custom event & let it bubble up. SignalRServerNotification(this, gArgs); }); SignalRGameHub.On<Game, InGameMessage>("inGameMessage", (g, im) => { SignalREventArgs gArgs = new SignalREventArgs(); gArgs.CustomGameObject = g; gArgs.InGameActionMessageEvent = im; // Raise custom event & let it bubble up. SignalRServerNotification(this, gArgs); }); }
public async virtual void Test(string x, User y) { // Post message to Server Chatroom. await SignalRGameHub.Invoke("Test", x, App.Current.AppUser); }
public async virtual void JoinGame(User x, Game g) { // Post message to Server Chatroom. await SignalRGameHub.Invoke("JoinGame", x, g); }
public async virtual void CreateGame(User tabletChatClient, Game game) { // Leave the Server's Chatroom. await SignalRGameHub.Invoke("CreateGame", tabletChatClient, game); }
public async virtual void UserUpdate(User tabletChatMessage, ServerMessage s) { // Post message to Server Chatroom. await SignalRGameHub.Invoke("UpdateUser", tabletChatMessage, s); }
private void itemclicked(object sender, ItemClickEventArgs e) { opponent = e.ClickedItem as User; App.Current.OppUserTest = e.ClickedItem as User; }