zoukankan      html  css  js  c++  java
  • 微信二次开发sdk使用教程--手机上发送了朋友圈通知服务端

    微信二次开发sdk使用教程--手机上发送了朋友圈通知服务端

    case CircleNewPublishNotice : {//手机上发送了朋友圈通知
    log.debug("socket:msgtype=CircleNewPublishNotice");
    circleNewPublishNoticeHandler.handleMsg(ctx, msgVo);
    break;
    }

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

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;

    import com.google.protobuf.util.JsonFormat;
    import com.jubotech.business.web.domain.AccountInfo;
    import com.jubotech.business.web.domain.WeChatAccountInfo;
    import com.jubotech.business.web.service.AccountService;
    import com.jubotech.business.web.service.WeChatAccountService;
    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.CircleNewPublishNotice.CircleNewPublishNoticeMessage;
    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 CircleNewPublishNoticeHandler{
    private final Logger log = LoggerFactory.getLogger(getClass());
    @Autowired
    private WeChatAccountService weChatAccountService;
    @Autowired
    private AccountService accountService;
    /**
    * 手机上发送了朋友圈通知
    * @author wechatno:tangjinjinwx
    * @param ctx
    * @param vo
    */
    public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {
    try {
    //log.info(JsonFormat.printer().print(vo.getContent()));
    CircleNewPublishNoticeMessage req = vo.getContent().unpack(CircleNewPublishNoticeMessage.class);
    log.info(JsonFormat.printer().print(req));
    // 把消息转发给pc端
    // a、根据wechatId找到accountid
    // b、通过accountid找到account
    // c、通过account账号找到通道
    WeChatAccountInfo account = weChatAccountService.findWeChatAccountInfoByWeChatId(req.getCircle().getWeChatId());
    if (null != account && null != account.getAccountid() && 1 != account.getIslogined()) {
    AccountInfo accInfo = accountService.findAccountInfoByid(account.getAccountid());
    if (null != accInfo) {
    // 转发给pc端
    ChannelHandlerContext chx = NettyConnectionUtil.getClientChannelHandlerContextByUserId(accInfo.getAccount());
    if (null != chx) {
    MessageUtil.sendJsonMsg(chx, EnumMsgType.CircleNewPublishNotice, NettyConnectionUtil.getNettyId(chx),null, req);
    }
    }
    // 告诉客户端消息已收到
    MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null);
    } else {
    // 对方不在线
    MessageUtil.sendErrMsg(ctx, EnumErrorCode.TargetNotOnline, Constant.ERROR_MSG_NOTONLINE);
    }

        } 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

  • 相关阅读:
    mysql常用时间列表的查询——七天内、本月、本周、某天
    js取数组获取最大值的四种方式
    Mysql按周,按月,按日,按小时分组统计数据
    Mysql中的sum函数为null时的解决办法
    Maven 中 dependencyManagement 标签使用
    嵌入式printf函数运用基于ti 16位MCU
    md5实现对用户名与密码的保护
    c# md5 算法实现
    define a struct
    file.open异常处理
  • 原文地址:https://www.cnblogs.com/wuliaokankan/p/10607849.html
Copyright © 2011-2022 走看看