Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        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);
        }