抖⾳上的程序代码java_抖⾳sdk,抖⾳api接⼝java调⽤源代码抖⾳sdk,抖⾳api接⼝
1、抖⾳上线下线
/**
* 抖⾳上线通知
* @author wechat:happybabby110
*/松辽盆地
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 与通道
DeviceInfo device = Imei());
if(null != device){
//做个保护,如果当前微信号在其他设备上登陆过,就把之前那条记录删除
if(!StringUtils.ImUid()) && !StringUtils.Imei())){
if(!StringUtils.Imuid()) && !ImUid().Imuid())){
device.tAvatar("");
device.tImuid("");
device.tNickname("");
device.tIsonline(1);
deviceService.update(device);
}
}
//设置新的参数
device.ImUid());
device.NickName());
device.Avatar());优秀团队
device.GenderValue());
device.Phone());
device.UniqueId());
device.Province());
device.City());
device.District());
device.Signature());
device.AwemeCount());
device.FollowingCount());
device.FollowerCount());
device.FriendCount());
//改为上线状态
device.tIsonline(0);//上线
deviceService.update(device);
/
/3、告诉客户端消息已收到
MessageUtil.ndMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null); asyncTaskService.ImUid(), EnumMsgType.ImOnlineNotice, req);
}
}
} catch (Exception e) {
e.printStackTrace();
MessageUtil.ndErrMsg(ctx, EnumErrorCode.Id(), e.getMessage());
}
}
/**
* 抖⾳下线通知
* @author wechat:happybabby110
*/
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 = ImUid());
if (null != account) {
account.tIsonline(1);// 下线
deviceService.update(account);
asyncTaskService.ImUid(), EnumMsgType.ImOfflineNotice, req);
我的梦想的作文
}
// 3、告诉客户端消息已收到
MessageUtil.ndMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null);
} el {
MessageUtil.ndErrMsg(ctx, EnumErrorCode.InvalidParam, vo.getId(), Constant.ERROR_MSG_ILLEGALDEVICE); }
} catch (Exception e) {
e.printStackTrace();
MessageUtil.ndErrMsg(ctx, EnumErrorCode.InvalidParam, vo.getId(), Constant.ERROR_MSG_DECODFAIL);
}
}
2、抖⾳粉丝或好友收发消息
/**
* 给抖⾳粉丝或好友发消息
* @author wechat:happybabby110
*/
@Async
public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {
try {
log.debug(contentJsonStr);
TalkToFriendTaskMessage.Builder bd = wBuilder();
JsonFormat.parr().merge(contentJsonStr, bd);
TalkToFriendTaskMessage req = bd.build();
//将消息转发送给⼿机客户端
asyncTaskService.msgSend2Phone(ctx, ImUid(), EnumMsgType.TalkToFriendTask, vo, req);
} catch (Exception e) {
e.printStackTrace();
MessageUtil.ndJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
}
}
/**
* 抖⾳聊天消息实时推送
* @author wechat:happybabby110
*/
@Async
public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {
try {
ChatMsgNoticeMessage req = vo.getContent().unpack(ChatMsgNoticeMessage.class);
log.debug(JsonFormat.printer().print(req));
log.w()+" ChatMsgNoticeMessage 对应的线程名: "+Thread.currentThread().getName()); //消息转发到pc端
asyncTaskService.ImUid(), EnumMsgType.ChatMsgNotice, req);
// 告诉客户端消息已收到
MessageUtil.ndMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null);
} catch (Exception e) {
e.printStackTrace();
MessageUtil.ndErrMsg(ctx, EnumErrorCode.Id(), e.getMessage());
}平菇怎么种植
}
3、关注与取消关注抖⾳号
/**
* @author wechat:happybabby110
* 关注抖⾳号
*/
@Async
public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {
try {
log.debug(contentJsonStr);
FollowTaskMessage.Builder bd = wBuilder();
JsonFormat.parr().merge(contentJsonStr, bd);
FollowTaskMessage req = bd.build();
//将消息转发送给⼿机客户端
asyncTaskService.msgSend2Phone(ctx, ImUid(), EnumMsgType.FollowTask, vo, req);球蛋白偏高是什么原因
} catch (Exception e) {
煎药方法e.printStackTrace();
MessageUtil.ndJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
}
}
/**
* 取消关注抖⾳号
* @author wechat:happybabby110
*/
观察的名言@Async
public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {
try {
log.debug(contentJsonStr);
UnFollowTaskMessage.Builder bd = wBuilder();
JsonFormat.parr().merge(contentJsonStr, bd);
UnFollowTaskMessage req = bd.build();
//将消息转发送给⼿机客户端
asyncTaskService.msgSend2Phone(ctx, ImUid(), EnumMsgType.UnFollowTask, vo, req);
} catch (Exception e) {
e.printStackTrace();
MessageUtil.ndJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL); }
}
4、同步抖⾳推荐的好友
/**
* 同步抖⾳推荐的好友
* @author wechat:happybabby110
*/
@Async
public void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {
try {
log.debug(contentJsonStr);
SyncRecFriendsTaskMessage.Builder bd = wBuilder();
JsonFormat.parr().merge(contentJsonStr, bd);
SyncRecFriendsTaskMessage req = bd.build();
//将消息转发送给⼿机客户端
asyncTaskService.msgSend2Phone(ctx, ImUid(), EnumMsgType.SyncRecFriendsTask, vo, req);