public void UserJoin(LoginTransportModel obj) { //var callbacks = _onlineUsers.Values.Select(u => u.Callback).ToList(); var currentUser = _chatDb.GetCurrentUser(obj.Mapping <LoginDataModel>()).Mapping <UserPartialTransportModel>(); var currentCallback = OperationContext.Current.GetCallbackChannel <IChatCallback>(); currentCallback.OnlineUsers(_chatDb.GetOnlineUsers(obj.Mapping <LoginDataModel>()).Mapping <UserCollectionTransportModel>()); currentCallback.CurrentUser(currentUser); currentCallback .UnreadMessages(_chatDb.GetUnreadMessages(currentUser.Mapping <LoginSuccessDataModel>()) .Mapping <UnreadMessagesTransportModel>()); //_onlineUserCallbacks.Values.ForEach(u => u.UserJoin(currentUser)); foreach (var pair in _onlineUserCallbacks) { var joinUser = currentUser.Mapping <OnlineUserTransportModel>(); joinUser.Relation = (UserRelationTransport)_chatDb .GetUserRelation(new UserRelationDataModel { CurrentUserId = pair.Key, RelationUserId = currentUser.Id }).Relation; pair.Value.UserJoin(joinUser); } _onlineUserCallbacks.Add(currentUser.Id, currentCallback); }
public LoginResultTransportModel Login(LoginTransportModel obj) { var resultLogin = _chatDb.Login(obj.Mapping <LoginDataModel>()) .Mapping <LoginResultTransportModel>(); if (resultLogin.Result == LoginResultTransport.Ok) { _messenger.UserJoin(obj); } return(resultLogin); }