抖音群控sdk,抖音云控api接口

1、抖音上线下线

/**

* 抖音上线通知

* @author wechat:happybabby110

* @blog http://www.wlkankan.cn

*/

public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {

try {

ImOnlineNoticeMessage req = vo.getContent().unpack(ImOnlineNoticeMessage.class);

log.debug(JsonFormat.printer().print(req));

//1、校验用户信息

if(null != req){

//2、存储全局id 与通道

NettyConnectionUtil.registerUserid(req.getImUid(),ctx);

DeviceInfo device = deviceService.getByDeviceid(req.getImei());

if(null != device){

//做个保护,如果当前微信号在其他设备上登陆过,就把之前那条记录删除

if(!StringUtils.isBlank(req.getImUid()) && !StringUtils.isBlank(req.getImei())){

if(!StringUtils.isEmpty(device.getImuid()) && !req.getImUid().equals(device.getImuid())){

device.setAvatar("");

device.setImuid("");

device.setNickname("");

device.setIsonline(1);

deviceService.update(device);

}

}

//设置新的参数

device.setImuid(req.getImUid());

device.setNickname(req.getNickName());

device.setAvatar(req.getAvatar());

device.setGender(req.getGenderValue());

device.setPhone(req.getPhone());

device.setUniqueid(req.getUniqueId());

device.setProvince(req.getProvince());

device.setCity(req.getCity());

device.setDistrict(req.getDistrict());

device.setSignature(req.getSignature());

device.setAwemecount(req.getAwemeCount());

device.setFollowingcount(req.getFollowingCount());

device.setFollowercount(req.getFollowerCount());

device.setFriendcount(req.getFriendCount());

//改为上线状态

device.setIsonline(0);//上线

deviceService.update(device);

//3、告诉客户端消息已收到

MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null);

asyncTaskService.msgSend2pc(req.getImUid(), EnumMsgType.ImOnlineNotice, req);

}

}

} catch (Exception e) {

e.printStackTrace();

MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam,vo.getId(), e.getMessage());

}

}

/**

* 抖音下线通知

* @author wechat:happybabby110

* @blog http://www.wlkankan.cn

*/

public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {

try {

ImOfflineNoticeMessage req = vo.getContent().unpack(ImOfflineNoticeMessage.class);

log.debug(JsonFormat.printer().print(req));

if (null != req) {

// 把消息转发给pc端

DeviceInfo account = deviceService.getByImUid(req.getImUid());

if (null != account) {

account.setIsonline(1);// 下线

deviceService.update(account);

asyncTaskService.msgSend2pc(req.getImUid(), EnumMsgType.ImOfflineNotice, req);

}

// 3、告诉客户端消息已收到

MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null);

} else {

MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam, vo.getId(), Constant.ERROR_MSG_ILLEGALDEVICE);

}

} catch (Exception e) {

e.printStackTrace();

MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam, vo.getId(), Constant.ERROR_MSG_DECODFAIL);

}

}

2、抖音粉丝或好友收发消息

/**

* 给抖音粉丝或好友发消息

* @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());

}

}

3、关注与取消关注抖音号

/**

* @author wechat:happybabby110

* @blog http://www.wlkankan.cn

* 关注抖音号

*/

@Async

public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {

try {

log.debug(contentJsonStr);

FollowTaskMessage.Builder bd = FollowTaskMessage.newBuilder();

JsonFormat.parser().merge(contentJsonStr, bd);

FollowTaskMessage req = bd.build();

//将消息转发送给手机客户端

asyncTaskService.msgSend2Phone(ctx, req.getImUid(), EnumMsgType.FollowTask, 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, String contentJsonStr) {

try {

log.debug(contentJsonStr);

UnFollowTaskMessage.Builder bd = UnFollowTaskMessage.newBuilder();

JsonFormat.parser().merge(contentJsonStr, bd);

UnFollowTaskMessage req = bd.build();

//将消息转发送给手机客户端

asyncTaskService.msgSend2Phone(ctx, req.getImUid(), EnumMsgType.UnFollowTask, vo, req);

} catch (Exception e) {

e.printStackTrace();

MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);

}

}

4、同步抖音推荐的好友

/**

* 同步抖音推荐的好友

* @author wechat:happybabby110

* @blog http://www.wlkankan.cn

*/

@Async

public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {

try {

log.debug(contentJsonStr);

SyncRecFriendsTaskMessage.Builder bd = SyncRecFriendsTaskMessage.newBuilder();

JsonFormat.parser().merge(contentJsonStr, bd);

SyncRecFriendsTaskMessage req = bd.build();

//将消息转发送给手机客户端

asyncTaskService.msgSend2Phone(ctx, req.getImUid(), EnumMsgType.SyncRecFriendsTask, 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 {

RecFriendsPushNoticeMessage req = vo.getContent().unpack(RecFriendsPushNoticeMessage.class);

log.debug(JsonFormat.printer().print(req));

log.debug(LocalDateTime.now()+" RecFriendsPushNoticeMessage 对应的线程名: "+Thread.currentThread().getName());

//消息转发到pc端

asyncTaskService.msgSend2pc(req.getImUid(), EnumMsgType.RecFriendsPushNotice, 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());

}

}

5、同步抖音聊天会话列表

/**

* 同步抖音会话列表

* @author wechat:happybabby110

* @blog http://www.wlkankan.cn

*/

@Async

public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {

try {

log.debug(contentJsonStr);

SyncConversationTaskMessage.Builder bd = SyncConversationTaskMessage.newBuilder();

JsonFormat.parser().merge(contentJsonStr, bd);

SyncConversationTaskMessage req = bd.build();

//将消息转发送给手机客户端

asyncTaskService.msgSend2Phone(ctx, req.getImUid(), EnumMsgType.SyncConversationTask, 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 {

ConversationPushNoticeMessage req = vo.getContent().unpack(ConversationPushNoticeMessage.class);

log.debug(JsonFormat.printer().print(req));

log.debug(LocalDateTime.now()+" ConversationPushNoticeMessage 对应的线程名: "+Thread.currentThread().getName());

//消息转发到pc端

asyncTaskService.msgSend2pc(req.getImUid(), EnumMsgType.ConversationPushNotice, 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());

}

}

6、同步抖音粉丝列表

/**

* 同步抖音粉丝

* @author wechat:happybabby110

* @blog http://www.wlkankan.cn

*/

@Async

public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {

try {

log.debug(contentJsonStr);

SyncFollowersTaskMessage.Builder bd = SyncFollowersTaskMessage.newBuilder();

JsonFormat.parser().merge(contentJsonStr, bd);

SyncFollowersTaskMessage req = bd.build();

//将消息转发送给手机客户端

asyncTaskService.msgSend2Phone(ctx, req.getImUid(), EnumMsgType.SyncFollowersTask, 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 {

FollowersPushNoticeMessage req = vo.getContent().unpack(FollowersPushNoticeMessage.class);

log.debug(JsonFormat.printer().print(req));

log.debug(LocalDateTime.now()+this.getClass().getName()+"对应的线程名: "+Thread.currentThread().getName());

//消息转发到pc端

asyncTaskService.msgSend2pc(req.getImUid(), EnumMsgType.FollowersPushNotice, 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());

}

}

java云控_抖音群控sdk,抖音云控api接口java调用代码相关推荐

  1. 个人微信api接口java调用代码

    个人微信api接口java调用代码 1.微信好友收发消息         /**      * 给微信好友发消息      * @author wechatno:tangjinjinwx      * ...

  2. oss客户端工具_干货 | 基于Go SDK操作京东云对象存储OSS的入门指南

    前言 本文介绍如何使用Go语言对京东云对象存储OSS进行基本的操作,帮助客户快速通过Go SDK接入京东云对象存储,提高应用开发的效率. 在实际操作之前,我们先看一下京东云OSS的API接口支持范围和 ...

  3. ie浏览器java 脚本下载_如何设置ie浏览器中的activex控件和插件java脚本下载用户验证...

    ActiveX是Microsoft提出的一组使用COM(ComponentObjectModel,部件对象模型)使得软件部件在网络环境中进行交互的技术集.它与具体的编程语言无关.作为针对Interne ...

  4. 华为智能家居app未能连接上远程云服务_【InForSec通讯】智能家居云平台实体间交互状态安全分析 | Usenix2019...

    论文题目:Discovering and Understanding the Security Hazards in the Interactions between IoT Devices, Mob ...

  5. java后端语言_后端程序员一定要看的语言大比拼:Java vs. Go vs. Rust

    这是Java,Go和Rust之间的比较.这不是基准测试,更多是对可执行文件大小.内存使用率.CPU使用率.运行时要求等的比较,当然还有一个小的基准测试,可以看到每秒处理的请求数量,我将尝试对这些数字进 ...

  6. 380免费云存储_从四个方面分析:云存储服务的特点、影响

    云存储就是将储存资源放到云上供人存取的一种新兴方案,使用者可以在任何时间.任何地方,透过任何可连网的装置连接到云上方便地存取数据.那么,云存储服务有什么特点,会给我们带来一些什么样的影响呢? 云存储是 ...

  7. 张敬富审计百度云资源_钟平逻辑英语资源百度云

    钟平英语百度网盘资源: 一.钟平21套 01.逻语系列一站到底(全5阶) 02.逻辑英语系列(全五阶) 03.大数据单词班 04.英语死磕班系列 05.17年冬令营 06.学渣语法逆袭班 07.痴学社 ...

  8. java 消息签名_微信公众平台消息体签名及加解密实例(Java)

    前言: 最近在研究微信公众平台的开发,玩得不亦乐乎.基本的回复功能已经实现了,而且回复用到了图灵机器人的接口.其实图灵机器人已经有微信接口可以直接调用.如果项目的需要,想要做个性化需求的话,用这种方式 ...

  9. java 新浪短链接_新浪(t.cn)短网址链接生成api接口

    最新的新浪(t.cn)短网址生成api接口,快速生成t.cn超短链接,接口可以正常调用,觉得不错可以收藏一下. 新浪短网址api接口: 使用说明: 将api接口地址中 "http://www ...

最新文章

  1. 题目1460:Oil Deposit
  2. 使用service实现登录、权限控制
  3. linux命令ping
  4. 【论文笔记】CNN for NLP
  5. VBRK-RFBSK - 会計への転記ステータス
  6. golang学习之旅(1)
  7. 蓝奏网盘直链转换器 v1.1
  8. python安装完后还需要装什么_初学 Python 需要安装哪些软件?
  9. java JLabel改变大小后如何刷新_到底一行java代码是如何在计算机上执行的
  10. 爱立信卫翰思:已囊括拉美一半以上…
  11. comps电磁场模拟软件_电力系统仿真软件综述说课.ppt
  12. 为Clion配置mingw32或mingw64
  13. 做硬件,真的没前途吗?看看资深工程师是怎么说的
  14. Web运维之安全配置指导手册
  15. Cy5 COOH非活性染料溶于有机溶剂1032678-07-1 科研
  16. Windows 7的应用程序兼容性和絮叨的应用程序兼容性助手
  17. 个人博客配置SSL安全文件
  18. 网络安全绝地求生-面试题
  19. pandas duplicated() 重复行标记与drop_duplicates()删除
  20. 高端访谈实录:访思科英国CEO菲尔·史密斯

热门文章

  1. 视觉传达设计在计算机中的应用,计算机图形在视觉传达设计中的应用
  2. Python+selenium(一)
  3. python学习笔记之Day1
  4. Arduino-uno-rev3基础知识
  5. Continual Learning 经典方法:Memory Aware Synapses (MAS)
  6. AI为超级马里奥兄弟创造了游戏新级别——GECCO 2018最佳论文提名
  7. 3damx插件dle无法初始化 126找不到指定的模块
  8. 天猫店群是什么?有什么内幕吗?值得投资去做天猫店群吗?
  9. 小清新版终端工具cmder配置
  10. Android记账本