zoukankan      html  css  js  c++  java
  • 抖音api接口调用-抖音粉丝或好友收发消息

    抖音sdk接口API调用-抖音粉丝或好友收发消息

    /**
    * 给抖音粉丝或好友发消息
    * @author wechat:happybabby110
    * @blog http://www.wlkankan.cn
    */
    @Async
    public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {
    try {
    log.debug(contentJsonStr);
    TalkToFriendTaskMessage.Builder bd = TalkToFriendTaskMessage.newBuilder();
    JsonFormat.parser().merge(contentJsonStr, bd);
    TalkToFriendTaskMessage req = bd.build();
    //将消息转发送给手机客户端
    asyncTaskService.msgSend2Phone(ctx, req.getImUid(), EnumMsgType.TalkToFriendTask, vo, req);
    } catch (Exception e) {
    e.printStackTrace();
    MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
    }
    }

    /**
    * 抖音聊天消息实时推送
    * @author wechat:happybabby110
    * @blog http://www.wlkankan.cn
    */
    @Async
    public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {
    try {
    ChatMsgNoticeMessage req = vo.getContent().unpack(ChatMsgNoticeMessage.class);
    log.debug(JsonFormat.printer().print(req));

            log.debug(LocalDateTime.now()+" ChatMsgNoticeMessage  对应的线程名: "+Thread.currentThread().getName());
               
            //消息转发到pc端
            asyncTaskService.msgSend2pc(req.getImUid(), EnumMsgType.ChatMsgNotice, req);
             
            // 告诉客户端消息已收到
            MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null);
              
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam,vo.getId(), e.getMessage());
        }
    }
  • 相关阅读:
    在客户端模拟调用srv和topic
    直流电机测试标准
    vue项目修改host实现地址代理,实现一键登录
    小程序 日期格式化
    ES6学习笔记之async函数
    ES6学习笔记之promise
    ES6学习笔记之箭头函数
    ES6学习笔记之var,let,const
    axios post后台接收不到参数
    vue-cli2配置scss遇到的各种坑
  • 原文地址:https://www.cnblogs.com/wuliaokankan/p/14137194.html
Copyright © 2011-2022 走看看