コード例 #1
0
        public InGameResponse InGame(InGameRequest inGameRequest)
        {
            //check authenticaiton:
            Guid    authentication = serviceLogic.GetHeaderAuthentication();
            UserDTO userGameSender = serviceLogic.TryGetUserByAuthentication(authentication);

            if (userGameSender == null)
            {
                return(new InGameResponse {
                    IsSuccess = false, Message = "User failed to authenticate"
                });
            }
            //check if the opponent is online and can get the request:
            IGameCallback callback;
            bool          IsRecipientOnline = callbacksByUserName.TryGetValue(inGameRequest.UserOpponent, out callback);

            if (IsRecipientOnline == false)
            {
                return(new InGameResponse {
                    IsSuccess = false, Message = "sorry the user can't get that Game Request right now"
                });
            }
            callback.OnInGame(new OnInGameRequest {
                UserName = userGameSender.UserName, SlotIdSource = inGameRequest.SlotIdSource, SlotIdDestination = inGameRequest.SlotIdDestination
            });
            return(new InGameResponse {
                IsSuccess = true, Message = "your move has sent to your opponent"
            });
        }
コード例 #2
0
 public InGameResponse InGame(InGameRequest inGameRequest)
 {
     using (new OperationContextScope((IClientChannel)proxy))
     {
         AuthenticatedUser currentLogedUser = AuthenticatedUser.Instance;
         WebOperationContext.Current.OutgoingRequest.Headers.Add("Authentication", currentLogedUser.Authentication.ToString());
         InGameResponse response = proxy.InGame(inGameRequest);
         return(response);
     }
 }