public JoinGameServiceResponse JoinService(JoinGameServiceRequest joinServiceRequest) { using (new OperationContextScope((IClientChannel)proxy)) { AuthenticatedUser currentLogedUser = AuthenticatedUser.Instance; WebOperationContext.Current.OutgoingRequest.Headers.Add("Authentication", currentLogedUser.Authentication.ToString()); JoinGameServiceResponse response = proxy.JoinService(joinServiceRequest); return(response); } }
public JoinGameServiceResponse JoinService(JoinGameServiceRequest joinServiceRequest) { //checking user authentication: Guid authentication = serviceLogic.GetHeaderAuthentication(); UserDTO UserGameSender = serviceLogic.TryGetUserByAuthentication(authentication); if (UserGameSender == null)//if user exist { return(new JoinGameServiceResponse { IsSuccess = false, Message = "user failed to authenticate you are not allowed to join this service" }); } //if user is authenticated - adding him to the chat service: IGameCallback callback = OperationContext.Current.GetCallbackChannel <IGameCallback>(); if (!callbacksByUserName.ContainsKey(UserGameSender.UserName)) {//from now on, this user will be able to get messages. callbacksByUserName.Add(UserGameSender.UserName, callback); } return(new JoinGameServiceResponse { IsSuccess = true, Message = "Joined the game service succesfully" }); }