コード例 #1
0
 public JoinChatServiceResponse JoinService(JoinChatServiceRequest joinServiceRequest)
 {
     using (new OperationContextScope((IClientChannel)proxy))
     {
         AuthenticatedUser currentLogedUser = AuthenticatedUser.Instance;
         WebOperationContext.Current.OutgoingRequest.Headers.Add("Authentication", currentLogedUser.Authentication.ToString());
         JoinChatServiceResponse response = proxy.JoinService(joinServiceRequest);
         return(response);
     }
 }
コード例 #2
0
ファイル: ChatService.cs プロジェクト: henbarlevi/TalkBack
        public JoinChatServiceResponse JoinService(JoinChatServiceRequest joinServiceRequest)
        {
            //checking user authentication:
            Guid    authentication    = serviceLogic.GetHeaderAuthentication();
            UserDTO UserMessageSender = serviceLogic.TryGetUserByAuthentication(authentication);

            if (UserMessageSender == null)//if user exist
            {
                return(new JoinChatServiceResponse {
                    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:
            IChatCallback callback = OperationContext.Current.GetCallbackChannel <IChatCallback>();

            if (!callbacksByUserName.ContainsKey(UserMessageSender.UserName))
            {//from now on, this user will be able to get messages.
                callbacksByUserName.Add(UserMessageSender.UserName, callback);
            }
            return(new JoinChatServiceResponse {
                IsSuccess = true, Message = "join the chat service succesfully"
            });
        }