/// <summary> /// Adds a chat message to the chat log stack, so it will be written in the database on the next cycle. /// </summary> /// <param name="sessionID">The ID of the session that chatted this message.</param> /// <param name="userID">The database ID of the user that chatted this message.</param> /// <param name="roomID">The database ID of the room where this message was chatted in.</param> /// <param name="receiverID">If the type of this chat message was a whisper, the database ID of the receiving user should be supplied here.</param> /// <param name="Type">A value of the 'chatType' enum, representing the type of this chat message.</param> /// <param name="Text">The actual chat message. Pass this argument with the 'ref' keyword please.</param> public void addChatMessageToLogStack(uint sessionID, int userID, int roomID, int receiverID, chatType Type, ref string Text) { if (this._logChat) { chatLog Log = new chatLog(sessionID, userID, roomID, receiverID, Type, Text); this.chatLogStack.Add(Log); } }
/// <summary> /// Constructs a chatLog object with given parameters. /// </summary> /// <param name="sessionID"></param> /// <param name="userID"></param> /// <param name="roomID"></param> /// <param name="receiverID"></param> /// <param name="Type"></param> /// <param name="Text"></param> public chatLog(uint sessionID, int userID, int roomID, int receiverID, chatType Type, string Text) { this.Timestamp = DateTime.Now; this.sessionID = sessionID; this.userID = userID; this.roomID = roomID; this.receiverID = receiverID; this.Type = Type; this.Text = Text; }
static readonly Util.ImageOptimizer.Compressor compressor = new Util.ImageOptimizer.Compressor();//图片压缩处理对象 public static string SendRetractMessage(string msgId, string to, chatType type = chatType.chat, int groupId = 0, SDKProperty.RetractType retractType = RetractType.Normal, SDKProperty.SessionType sessionType = SessionType.CommonChat, message.ReceiverInfo recverInfo = null) { MessagePackage package = new MessagePackage() { from = SDKClient.Instance.property.CurrentAccount.userID.ToString(), to = to, id = SDKProperty.RNGId }; package.data = new message() { body = new retractBody() { retractId = msgId, retractType = (int)retractType }, senderInfo = new message.SenderInfo() { photo = SDKClient.Instance.property.CurrentAccount.photo, userName = SDKClient.Instance.property.CurrentAccount.userName }, receiverInfo = recverInfo, subType = "retract", chatType = to == SDKClient.Instance.property.CurrentAccount.userID.ToString() ? (int)SessionType.FileAssistant : (int)sessionType, type = type == chatType.chat ? nameof(chatType.chat) : nameof(chatType.groupChat) }; if (type == chatType.groupChat) { package.data.groupInfo = new message.msgGroup() { groupId = groupId }; } package.Send(SDKClient.Instance.ec); return(package.id); }
/// <summary> /// 发送本文消息 /// </summary> /// <param name="content">消息内容</param> /// <param name="to">接收者</param> /// <param name="userIds">被@对象集合,@ALL定义为值-1</param> /// <param name="type">消息类型chat,groupchat</param> /// <returns>id</returns> public static string Sendtxt(string content, string to, IList <int> userIds = null, chatType type = chatType.chat, string groupName = null, SDKProperty.SessionType sessionType = SessionType.CommonChat, message.ReceiverInfo recverInfo = null) { MessagePackage package = new MessagePackage(); package.ComposeHead(to, SDKClient.Instance.property.CurrentAccount.userID.ToString()); package.data = new message() { body = new TxtBody() { text = content }, senderInfo = new message.SenderInfo() { photo = SDKClient.Instance.property.CurrentAccount.photo, userName = SDKClient.Instance.property.CurrentAccount.userName ?? SDKClient.Instance.property.CurrentAccount.loginId }, receiverInfo = recverInfo, chatType = to == SDKClient.Instance.property.CurrentAccount.userID.ToString() ? (int)SessionType.FileAssistant : (int)sessionType, subType = "txt", tokenIds = userIds, type = type == chatType.chat ? nameof(chatType.chat) : nameof(chatType.groupChat) }; if (type == chatType.groupChat) { package.data.groupInfo = new message.msgGroup() { groupId = to.ToInt(), groupName = groupName }; } package.Send(SDKClient.Instance.ec); return(package.id); }