Beispiel #1
0
        /// <summary>
        /// 方法说明:SDK发送聊天消息接口:文本、图片、音频、视频、文件、地理位置、图文混合、@消息、多人音频视频
        /// 完成时间:2017-05-16
        /// </summary>
        /// <param name="entity">发送消息实体</param>
        /// <param name="sendType">发送类型:正常聊天,重发聊天,机器人聊天</param>
        /// <param name="errorMsg">提示信息</param>
        /// <returns>是否成功发送消息</returns>
        public bool SdkPublishChatMsg <T>(T entity, ChatMsgSendType sendType, ref string errorMsg)
            where T : MsSdkMessageChat
        {
            var    jsonStr = MsgConverter.GetJsonByChatMsg <T>(entity, ref errorMsg);
            string topic;

            switch (sendType)
            {
            case ChatMsgSendType.Nomal:
            {
                topic = TopicSend.sdk_send.ToString();
            }
            break;

            case ChatMsgSendType.Repeat:
            {
                topic = TopicSend.sdk_resend.ToString();
            }
            break;

            case ChatMsgSendType.Robot:
            {
                topic = TopicSend.robot_send.ToString();
            }
            break;

            case ChatMsgSendType.Rerobot:
            {
                topic = TopicSend.robot_resend.ToString();
            }
            break;

            default:
            {
                topic = TopicSend.sdk_send.ToString();
            }
            break;
            }
            //发送消息
            return(!string.IsNullOrEmpty(jsonStr) && Publish(topic, jsonStr, false, ref errorMsg));
        }