internal void SendPieceSyncCommands (string matchId, string accountId, int playerSlot, GamePiece piece) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}{1}{7}{1}{8}{1}{9}{1}{10}{1}{11}{1}{12}{1}{13}{1}{14}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.SyncGamePiece), matchId, accountId, playerSlot, piece.NetworkIdentity, piece.GamePieceName, piece.BoardVector.x, piece.BoardVector.y, piece.CurrentHitPoints, piece.DefenseRating, piece.AttackRating, piece.TurnDelay, (int)piece.gameObject.transform.rotation.eulerAngles.y); Debug.Log("Sending: " + cmd); SendData(cmd); cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.EndGamePieceSync), matchId, accountId); Debug.Log("Sending: " + cmd); SendData(cmd); }
private void HandleMatchEndEvent(string matchId) { string cmd = string.Format("{0}{1}{2}{1}{3}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.EndMatch), matchId); ClientManager.SendMessageToAllClients(cmd); }
private void HandleLobbyMessage_One(string id, string[] segments) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.LobbyMessage), segments[2], segments[3], segments[4]); ClientManager.SendMessageToAllClients(cmd); }
internal void AttemptLogin(string username, string password) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.Login), username, password); Debug.Log("Sending: " + cmd); SendData(cmd); }
private void HandleMatchJoinResult(ClientState client, string matchId, bool succeeeded) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.JoinMatchResult), succeeeded.ToString(), matchId); client.SendData(cmd); }
private void InterEventDispatcher_MatchStartEvent(MatchStartEventArgs args) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.StartMatch), args.MatchId, args.PlayerIdOfFirstToMove); MatchHandler.SendMessageToUsersInMatch(args.MatchId, cmd); }
internal void SendCirculationCommand() { string cmd = string.Format("{0}{1}{2}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.Heartbeat)); Debug.Log("Sending: " + cmd); SendData(cmd); }
internal void SendLogoutNotification() { string cmd = string.Format("{0}{1}{2}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.LogOut)); Debug.Log("Sending: " + cmd); SendData(cmd); }
internal void SendFriendRemovalNotification(Account account) { string cmd = string.Format("{0}{1}{2}{1}{3}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.RemoveFriend), account.Identity); Debug.Log("Sending: " + cmd); SendData(cmd); }
private void NetworkEventDispatcher_ClientCirculationEvent(ClientCirculationEventArgs args) { string cmd = string.Format("{0}{1}{2}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.Heartbeat)); if (args.ClientState != null) { args.ClientState.SendData(cmd); } }
private void SendSpectatorDepartureNotification(string matchId, PlayerState spectator) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.RemoveSpectator), matchId, spectator.AccountIdentity, spectator.Username); ClientManager.SendMessageToAllClients(cmd); }
private void MatchEventDispatcher_SpectatorSyncEvent(SpectatorSyncEventArgs args) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.SyncMatchSpectator), args.Match.MatchIdentity, args.PlayerState.AccountIdentity, args.PlayerState.Username); MatchHandler.SendMessageToUsersInMatch(args.Match, cmd); }
internal void SendSpectateMatchCommand(string matchId) { //Protocol#|spcmtch#|matchId string cmd = string.Format("{0}{1}{2}{1}{3}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.SpectateMatch), matchId); Debug.Log("Sending: " + cmd); SendData(cmd); }
private void InterEventDispatcher_TurnStateSyncEvent(TurnStateSyncEventArgs args) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.TurnStateSync), args.MatchId, args.CurrentPlayerId, args.TurnStep.ToString(), args.LowestTurnStep.ToString()); MatchHandler.SendMessageToUsersInMatch(args.MatchId, cmd); }
internal void SendTurnUpdateCommand(string matchId, int turnStep) { //protocol#|cmd#|matchId#|step string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.TurnStateUpdate), matchId, turnStep.ToString()); Debug.Log("Sending: " + cmd); SendData(cmd); }
internal void SendStartMatchCommand(Account account) { //protocol#|crtmtch#|userId#|username string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.CreateMatch), account.Identity, account.Username); Debug.Log("Sending: " + cmd); SendData(cmd); }
private void InterEventDispatcher_AttackSyncCompleteEvent(AttackSyncCompleteEventArgs args) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}{1}{7}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.ProcessAttack), args.MatchId, args.AttackingPieceId, args.DefendingPlayerId, args.BoardVectorX.ToString(), args.BoardVectorY.ToString()); MatchHandler.SendMessageToUsersInMatch(args.MatchId, cmd); }
private void HandleMatchMessage_One(string[] segments) { //protocol#|lbymsg#|matchId#|username#|time#|message<#> string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.MatchMessage), segments[2], segments[3], segments[4], segments[5]); MatchHandler.SendMessageToUsersInMatch(segments[2], cmd); }
private void NetworkEventDispatcher_AccountCreationSucessEvent(AccountCreationSuccessArgs args) { ClientState client = ClientManager.GetClientById(args.ClientId); if (client != null) { string s = (string.Format("{0}{1}{2}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.AccountCreated))); client.SendData(s); } }
private void NetworkEventDispatcher_UserLoginEvent(UserLoginEventArgs args) { try { ClientState client = ClientManager.GetClientById(args.ClientId); if (client != null) { if (args.Success) { Account account = new Account(args.ClientId, args.Username); AccountHandler.AddOnlineAccount(account); client.Authorize(account); //0#|lgnsccs#|username#|email#|rating#|wins#|losses#|id string s = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}{1}{7}{1}{8}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.LoginSuccess), account.Username, account.Email, account.Rating, account.Wins, account.Losses, account.AccountId); client.SendData(s); SendAllAccountSyncDataToClient(client, AccountSyncType.Connect); SendAccountSyncDataToAllClients(account, client, AccountSyncType.Connect); SyncUserFriends(account); SyncAllAvailableMatchesWithClient(client); } else { string s = string.Format("{0}{1}{2}{1}{3}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.LoginFail), args.LoggedIn.ToString()); client.SendData(s); } } } catch (Exception e) { Console.WriteLine(e.ToString()); } }
private void SyncMatchSpectators(MatchState match) { foreach (PlayerState state in match.Spectators.Values.ToList()) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.SyncMatchSpectator), match.MatchIdentity, state.AccountIdentity, state.Username); ClientManager.SendMessageToAllClients(cmd); } }
private string GetFriendSyncCommand(Account account) { //protocol#|sncfrnd#|username#|rating#|wins#|losses#|id string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}{1}{7}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.SyncFriend), account.Username, account.Rating, account.Wins, account.Losses, account.AccountId); return(cmd); }
private void HandleSpectatorJoinEvent(string matchId, string clientId, bool succeeded) { MatchState match = MatchHandler.GetMatchStateById(matchId); string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.SpectateMatchResult), matchId, succeeded.ToString().ToLowerInvariant()); ClientManager.GetClientById(clientId).SendData(cmd); SyncMatchSpectators(match); }
//protocol#|pvtmsg#|from#|to#|time#|message internal void SendPrivateMessage(string message, Account accountTo, Account accountFrom) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.PrivateMessage), accountFrom.Identity, accountTo.Identity, DateTime.UtcNow.ToShortTimeString(), message); Debug.Log("Sending: " + cmd); SendData(cmd); }
private void HandlePrivateMessage_One(string[] segments) { //protocol#|pvtmsg#|from#|to#|time#|message string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.PrivateMessage), segments[2], segments[3], segments[4], segments[5]); ClientManager.SendMessageToClientByAccount (AccountHandler.GetAccountById(segments[3]), cmd); }
//protocol#|lbymsg#|matchId#|username#|time#|message<#> internal void SendMatchMessage(string message, string matchId) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.MatchMessage), matchId, AccountManager.AccountInstance.Username, DateTime.UtcNow.ToShortTimeString(), message); Debug.Log("Sending: " + cmd); SendData(cmd); }
private void HandleNetworkPieceMove_One(string[] segments) { //protocol#|command#|matchId#|pieceNetId#|x#|y string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.NetworkPieceMoveEvent), segments[2], segments[3], segments[4], segments[5]); MatchHandler.SendMessageToUsersInMatch(segments[2], cmd); }
//protocol#|crtacct#|username#|password#|email<#> internal void RequestNewAccount(string username, string password, string email) { string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.CreateAccount), username, password, email); Debug.Log("Sending: " + cmd); SendData(cmd); }
private string GetMatchSyncCommand(MatchState match) { //protocol#|mtchcrtd#|matchId#|playerOneId#|playerOneUsername#|playerTwoId#|playerTwoUsername string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}{1}{7}{1}{8}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.SyncMatchParticipants), match.MatchIdentity, match.PlayerOne != null ? match.PlayerOne.AccountIdentity : "-1", match.PlayerOne != null ? match.PlayerOne.Username : "******", match.PlayerTwo != null ? match.PlayerTwo.AccountIdentity : "-1", match.PlayerTwo != null ? match.PlayerTwo.Username : "******", match.InProgress.ToString()); return(cmd); }
private string GetAccountSyncCommand(Account account, AccountSyncType syncType) { //protocol#|syncfacct#|syncType#|username#|rating#|wins#|losses<#> string cmd = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}{1}{6}{1}{7}{1}{8}", (int)ReadProtocol.GetVersion(), m_SegmentTerminator, NetworkCommand.GetCommand(NetworkCommandType.SyncForeignAccount), (int)syncType, account.Username, account.Rating, account.Wins, account.Losses, account.AccountId); return(cmd); }