我是靠谱客的博主 冷静镜子,这篇文章主要介绍微信开发SDK使用教程--朋友圈点赞任务,现在分享给大家,希望可以做个参考。

微信开发SDK使用教程--朋友圈点赞任务

case "PostMomentsPraiseTask": {// 朋友圈点赞任务
log.debug("websocket:msgtype=PostMomentsPraiseTask。。。。。");
postMomentsPraiseTaskWebsocketHandler.handleMsg(ctx, vo, contentJsonStr);
break;
}

package com.jubotech.framework.netty.handler.websocket;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.google.protobuf.util.JsonFormat;
import com.jubotech.framework.netty.common.Constant;
import com.jubotech.framework.netty.utils.MessageUtil;
import com.jubotech.framework.netty.utils.NettyConnectionUtil;

import Jubo.JuLiao.IM.Wx.Proto.PostMomentsPraiseTask.PostMomentsPraiseTaskMessage;
import Jubo.JuLiao.IM.Wx.Proto.TransportMessageOuterClass.EnumErrorCode;
import Jubo.JuLiao.IM.Wx.Proto.TransportMessageOuterClass.EnumMsgType;
import Jubo.JuLiao.IM.Wx.Proto.TransportMessageOuterClass.TransportMessage;
import io.netty.channel.ChannelHandlerContext;

@Service
public class PostMomentsPraiseTaskWebsocketHandler{
private final Logger log = LoggerFactory.getLogger(getClass());
/**
* 朋友圈点赞任务---pc端经过服务端转发给手机端
* @author wechatno:tangjinjinwx
* @param ctx
* @param vo
*/
public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo, String contentJsonStr) {
try {
log.info(contentJsonStr);
PostMomentsPraiseTaskMessage.Builder bd = PostMomentsPraiseTaskMessage.newBuilder();
JsonFormat.parser().merge(contentJsonStr, bd);
PostMomentsPraiseTaskMessage req = bd.build();
//将消息转发送给手机客户端
ChannelHandlerContext cx= NettyConnectionUtil.getClientChannelHandlerContextByUserId(req.getWeChatId());
if(null != cx){
MessageUtil.sendMsg(cx, EnumMsgType.PostMomentsPraiseTask, NettyConnectionUtil.getNettyId(ctx), null, req);
//告诉客户端消息已收到
MessageUtil.sendJsonMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null);
}else{
// 对方不在线
MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.TargetNotOnline, Constant.ERROR_MSG_NOTONLINE);
}

复制代码
1
2
3
4
5
6
} catch (Exception e) { e.printStackTrace(); MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL); } }

}

项目地址:https://www.wuliaokankan.cn/url301/138.html
接口参考:http://www.yunlauncher.com/Blog/articles/119.html

转载于:https://www.cnblogs.com/wuliaokankan/p/10656035.html

最后

以上就是冷静镜子最近收集整理的关于微信开发SDK使用教程--朋友圈点赞任务的全部内容,更多相关微信开发SDK使用教程--朋友圈点赞任务内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(79)

评论列表共有 0 条评论

立即
投稿
返回
顶部