zoukankan      html  css  js  c++  java
  • 微信机器人开发SDK使用教程-- 触发手机推送好友列表任务

    微信机器人开发SDK使用教程-- 触发手机推送好友列表任务

    case "TriggerFriendPushTask": {// 触发手机推送好友列表任务
    log.debug("websocket:msgtype=TriggerFriendPushTask。。。。。");
    triggerFriendPushTaskWebsocketHandler.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.TransportMessageOuterClass.EnumErrorCode;
    import Jubo.JuLiao.IM.Wx.Proto.TransportMessageOuterClass.EnumMsgType;
    import Jubo.JuLiao.IM.Wx.Proto.TransportMessageOuterClass.TransportMessage;
    import Jubo.JuLiao.IM.Wx.Proto.TriggerFriendPushTask.TriggerFriendPushTaskMessage;
    import io.netty.channel.ChannelHandlerContext;

    @Service
    public class TriggerFriendPushTaskWebsocketHandler{
    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);
    TriggerFriendPushTaskMessage.Builder bd = TriggerFriendPushTaskMessage.newBuilder();
    JsonFormat.parser().merge(contentJsonStr, bd);
    TriggerFriendPushTaskMessage req = bd.build();
    //TriggerFriendPushTaskMessage req = vo.getContent().unpack(TriggerFriendPushTaskMessage.class);

        	//将消息转发送给手机客户端
        	ChannelHandlerContext cx=	NettyConnectionUtil.getClientChannelHandlerContextByUserId(req.getWeChatId());
        	if(null != cx){
        		MessageUtil.sendMsg(cx, EnumMsgType.TriggerFriendPushTask, 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);
        	}
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
        }
    }
    

    }

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

  • 相关阅读:
    SQL Server创建索引的技巧分析
    SQL Server创建索引
    kmp算法的应用
    相交环的面积
    Rebranding
    Olympiad
    找新朋友
    卡特兰数
    越狱
    Wolf and Rabbit
  • 原文地址:https://www.cnblogs.com/wuliaokankan/p/10655975.html
Copyright © 2011-2022 走看看