/// <summary> /// 建構函數 /// </summary> /// <param name="userId">成員 Id</param> /// <param name="group">群組</param> /// <param name="status">關係狀態</param> /// <param name="date">建立時間</param> /// <param name="readTime">最後讀取時間</param> public GroupMember(long userId, Group group, RelationshipStatus status, DateTime date, DateTime readTime) : base(date) { this.UserId = userId; this.Group = group; this.Status = status; this.ReadTime = readTime; }
/// <summary> /// 推送新群組到每個群組成員 /// </summary> /// <param name="group">群組</param> void PushGroupToClient(Group group) { var memberIds = group.Members.Select(m => m.UserId.ToString()).ToList(); GroupInfo groupInfo = new GroupInfo() { Id = group.Id, Members = group.Members.Select(m => new GroupInfo.GroupMember() { Id = m.UserId, ReadTime = m.ReadTime }), Name = group.Name, UnreadMessageCount = 0 }; if (group.Portrait != null){ groupInfo.PortraitUrl = PortraitController.GenerateUrl(group.Portrait.Filename); groupInfo.Thumbnail = group.Portrait.Thumbnail; } this.HubContext.Clients.Users(memberIds).updateRelationship(groupInfo); }