Beispiel #1
0
 public void SendStatusUpdatesToFriends(bool myOnlineStatus)
 {
     foreach (FriendsListEntry friend in AppServices.friendsData.friendsList)
     {
         if (friend.isOnline)
         {
             AppServices.appWarpLastSentToUsername = friend.username;
             if (friend.sessionEstablished)
             {
                 AppServices.warpClient.sendPrivateUpdate(friend.username, MessageBuilder.buildOnlineStatusUpdateBytes(true, friend.encryptionKey));
             }
             else
             {
                 AppServices.warpClient.sendPrivateUpdate(friend.username, MessageBuilder.buildOnlineStatusUpdateBytes(true, AppServices.defaultEncryptionKey));
             }
         }
     }
 }
Beispiel #2
0
        // This will be called after the user presses Login on the LoginPage and a session has been established using the App42 cloud API's
        //	this then connects and creates a session with the AppWarp API's which will be used for initial chat establishment and update
        //	messages for things like online status and message types.
        public void onConnectDone(com.shephertz.app42.gaming.multiplayer.client.events.ConnectEvent eventObj)
        {
            byte   result   = eventObj.getResult();
            string errorMsg = string.Empty;

            // If the connection was successful check which mode the call was made in and do the desired operation
            if (result == WarpResponseResultCode.SUCCESS)
            {
                AppServices.operationSuccessful = true;

                if (AppServices.appWarpConnectMode == appWarpConnectModes.sendAllUpdates)
                {
                    foreach (FriendsListEntry friend in AppServices.friendsData.friendsList)
                    {
                        if (friend.isOnline)
                        {
                            AppServices.appWarpLastSentToUsername = friend.username;
                            if (friend.sessionEstablished)
                            {
                                AppServices.warpClient.sendPrivateUpdate(friend.username, MessageBuilder.buildOnlineStatusUpdateBytes(true, friend.encryptionKey));
                            }
                            else
                            {
                                AppServices.warpClient.sendPrivateUpdate(friend.username, MessageBuilder.buildOnlineStatusUpdateBytes(true, AppServices.defaultEncryptionKey));
                            }
                        }
                    }
                }
                AppServices.appWarpConnectMode = appWarpConnectModes.justConnect;
                AppServices.appWarpLoggedIn    = true;
                return;
            }
            else if (result == WarpResponseResultCode.CONNECTION_ERROR_RECOVERABLE)
            {
                AppServices.warpClient.RecoverConnection();
                return;
            }
            else if (result == WarpResponseResultCode.SUCCESS_RECOVERED)
            {
                return;
            }
            else if (result == WarpResponseResultCode.AUTH_ERROR)
            {
                errorMsg = "Connect Authentication Error: Attempting to connect without initializing the API keys.";
            }
            else if (result == WarpResponseResultCode.BAD_REQUEST)
            {
                errorMsg = "Bad Request: The entered username does not exist.";
            }
            else if (result == WarpResponseResultCode.CONNECTION_ERR)
            {
                errorMsg = "Network Connection Error: Please check your network connection and try again.";
            }
            else
            {
                errorMsg = "Unknown Error: Please check your network connection and the entered username and try again.";
            }

            AppServices.operationSuccessful = false;
            AppServices.errorMessage        = errorMsg;
            AppServices.appWarpLoggedIn     = true;
        }
Beispiel #3
0
        public static void logout()
        {
            if (AppServices.appWarpLoggedIn)
            {
                // Tell all online friends I am offline
                foreach (FriendsListEntry friend in AppServices.friendsData.friendsList)
                {
                    if (friend.isOnline)
                    {
                        AppServices.appWarpLastSentToUsername = friend.username;
                        if (friend.sessionEstablished)
                        {
                            AppServices.warpClient.sendPrivateUpdate(friend.username, MessageBuilder.buildOnlineStatusUpdateBytes(false, friend.encryptionKey));
                        }
                        else
                        {
                            AppServices.warpClient.sendPrivateUpdate(friend.username, MessageBuilder.buildOnlineStatusUpdateBytes(false, AppServices.defaultEncryptionKey));
                        }
                    }
                }

                // Logout of AppWarp
                AppServices.warpClient.Disconnect();
            }

            if (AppServices.app42LoggedIn)
            {
                // Logout of App42 Services
                AppServices.sessionService.Invalidate(AppServices.localSessionId, new LogoutSessionCallback());
                AppServices.localSessionId = string.Empty;
            }

            AppServices.resetStatusVaribles();
        }