云控微信开发SDK使用教程--手机微信群二维码上传给服务端

云控微信开发SDK使用教程--手机微信群二维码上传给服务端

case PullChatRoomQrCodeTaskResultNotice : {//群二维码
log.debug("socket:msgtype=PullChatRoomQrCodeTaskResultNotice");
pullChatRoomQrCodeTaskResultNoticeHandler.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.PullChatRoomQrCodeTaskResultNotice.PullChatRoomQrCodeTaskResultNoticeMessage;
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 PullChatRoomQrCodeTaskResultNoticeHandler{
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 {
        PullChatRoomQrCodeTaskResultNoticeMessage req = vo.getContent().unpack(PullChatRoomQrCodeTaskResultNoticeMessage.class);
        log.info(JsonFormat.printer().print(req));
        WeChatAccountInfo account = weChatAccountService.findWeChatAccountInfoByWeChatId(req.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.PullChatRoomQrCodeTaskResultNotice,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://github.com/tangjinjinwx/Public.WeChat.CRM.SDK
接口参考:http://www.yunlauncher.com/Blog/articles/119.html

云控微信开发SDK使用教程--手机微信群二维码上传给服务端

上一篇:PHP出现 Notice: Undefined index:...的原因及解决办法


下一篇:Nodejs开发微信公众号中控服务