/// <summary> /// 提供向指定的Topic发布消息的能力,常用于向设备下发控制指令;该接口只适用于数据协议为“自定义”类型的产品,使用数据模板类型的产品需使用IssueDeviceControl接口 /// </summary> /// <param name="req">参考<see cref="PublishMsgRequest"/></param> /// <returns>参考<see cref="PublishMsgResponse"/>实例</returns> public async Task <PublishMsgResponse> PublishMsg(PublishMsgRequest req) { JsonResponseModel <PublishMsgResponse> rsp = null; try { var strResp = await this.InternalRequest(req, "PublishMsg"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <PublishMsgResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
public AopResult <PublishMsgResponse> Post(PublishMsgRequest request) { // 发布消息,需注册应用和事件 if (!base.ValidateApp(request.AppNo, request.AppEvent)) { return(AopResult.Fail <PublishMsgResponse>("非法调用!")); } var msgNo = NumHelper.GetRandomNo(); var msg = new MsgContent { MsgNo = msgNo, AppNo = request.AppNo, AppEvent = request.AppEvent, Content = request.Content }; // 记录消息日志 ServerHelper.GetLogImp.AddLog(msg); // 推送消息到队列 var queueId = ServerHelper.GetQueueImp.PushMsg(msg); return(AopResult.Success(new PublishMsgResponse { QueueId = queueId.ToString(), MsgNo = msgNo })); }