public void UpdateOnLineUserAsync(OnLineUserHubEntity onLineUser) { Task.Factory.StartNew(() => { letterDal.UpdateOnLineUser(onLineUser); }); }
public void OnConnected(string connectionId, long uId, long partnerUId, int connetType) { try { #region 在线信息 if (connetType == 0) { var onLineUser = userBiz.OnLineUser(uId); if (onLineUser == null) { onLineUser = new OnLineUserHubEntity() { OnLineId = Guid.NewGuid(), UId = uId, ConnectionId = connectionId, IsOnLine = true, CreateTime = DateTime.Now, UpdateTime = DateTime.Now }; userBiz.InsertOnLineUserAsync(onLineUser); } else { onLineUser.ConnectionId = connectionId; onLineUser.IsOnLine = true; onLineUser.UpdateTime = DateTime.Now; userBiz.UpdateOnLineUserAsync(onLineUser); } } #endregion #region 聊天页面在线状态 else if (connetType == 1) { var chatListHub = userBiz.ChatListHub(uId); if (chatListHub == null) { chatListHub = new ChatListHubEntity() { ChatListHubId = Guid.NewGuid(), UId = uId, ConnectionId = connectionId, IsOnLine = true, CreateTime = DateTime.Now, UpdateTime = DateTime.Now }; userBiz.InsertChatListHubAsync(chatListHub); } else { chatListHub.ConnectionId = connectionId; chatListHub.IsOnLine = true; chatListHub.UpdateTime = DateTime.Now; userBiz.UpdateChatListHubAsync(chatListHub); } } #endregion #region 聊天互动功能 else if (connetType == 2) { if (partnerUId > 0) { var userHub = userBiz.OnChatHub(uId); if (userHub == null) { userHub = new OnChatHubEntity() { OnChatHubId = Guid.NewGuid(), UId = uId, PartnerUId = partnerUId, ConnectionId = connectionId, IsOnLine = true, CreateTime = DateTime.Now, UpdateTime = DateTime.Now }; userBiz.InsertOnChatHubAsync(userHub); } else { userHub.ConnectionId = connectionId; userHub.IsOnLine = true; userHub.PartnerUId = partnerUId; userHub.UpdateTime = DateTime.Now; userBiz.UpdateOnChatHubAsync(userHub); } } } #endregion } catch (Exception ex) { LogHelper.ErrorAsync("SocketBiz.OnConnected", ex); } }