ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
抖音sdk抖音api接口调用,抖音上线下线 /** * 抖音上线通知 * @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); } } 抖音api接口,抖音sdk方案咨询微信happybabby110