Ejemplo n.º 1
0
        private void HandleFiendFriends(PeerBase peer, FindFriendsRequest request, SendParameters sendParameters)
        {
            try
            {
                var onlineList = new bool[request.UserList.Length];
                var gameIds = new string[request.UserList.Length];

                for (int i = 0; i < request.UserList.Length; i++)
                {
                    PlayerState playerState;
                    if (this.playerDict.TryGetValue(request.UserList[i], out playerState))
                    {
                        onlineList[i] = true;
                        if (playerState.ActiveGame != null)
                        {
                            gameIds[i] = playerState.ActiveGame.Id;
                        }
                        else
                        {
                            gameIds[i] = string.Empty;
                        }
                    }
                    else
                    {
                        gameIds[i] = string.Empty;
                    }
                }

                var response = new FindFriendsResponse { IsOnline = onlineList, UserStates = gameIds };
                var opResponse = new OperationResponse((byte)OperationCode.FindFriends, response);
                peer.SendOperationResponse(opResponse, sendParameters);
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Ejemplo n.º 2
0
 public void FiendFriends(PeerBase peer, FindFriendsRequest request, SendParameters sendParameters)
 {
     this.fiber.Enqueue(() => this.HandleFiendFriends(peer, request, sendParameters));
 }
Ejemplo n.º 3
0
        public OperationResponse HandleFindFriends(OperationRequest operationRequest, SendParameters sendParameters)
        {
            // validate the operation request
            OperationResponse response;
            var operation = new FindFriendsRequest(this.Protocol, operationRequest);
            if (OperationHelper.ValidateOperation(operation, log, out response) == false)
            {
                return response;
            }

            // check if player online cache is available for the application
            var playerCache = this.Application.PlayerOnlineCache;
            if (playerCache == null)
            {
                return new OperationResponse((byte)OperationCode.FindFriends)
                {
                    ReturnCode = (short)ErrorCode.InternalServerError,
                    DebugMessage = "PlayerOnlineCache is not set!"
                };
            }

            playerCache.FiendFriends(this, operation, sendParameters);
            return null;
        }