zoukankan      html  css  js  c++  java
  • 微信开发SDK使用教程--手机微信联系人信息上传服务端

    微信开发SDK使用教程--手机微信联系人信息上传服务端

    case ContactsInfoNotice : {// 微信联系人信息上传
    log.debug("socket:msgtype=ContactsInfoNotice");
    contactsInfoNoticeHandler.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.scheduling.annotation.Async;
    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.ContactsInfoNotice.ContactsInfoNoticeMessage;
    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 ContactsInfoNoticeHandler{
    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 {
        	ContactsInfoNoticeMessage req = vo.getContent().unpack(ContactsInfoNoticeMessage.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) {
    					asyncSendMsg(chx, 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);
        }
    }
    
    @Async
    private void asyncSendMsg(ChannelHandlerContext  chx ,ContactsInfoNoticeMessage req){
    	MessageUtil.sendJsonMsg(chx, EnumMsgType.ContactsInfoNotice,NettyConnectionUtil.getNettyId(chx), null, req);
    }
    

    }

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

  • 相关阅读:
    《白帽子讲web安全》学习笔记(第一篇)
    pytorch安装配置(VScode +miniconda+pytorch)
    tensorflow-GPU安装配置(VScode +miniconda+tensorflow-gpu)
    Win10+VScode +miniconda安装tensorflow(CPU版本)
    The TensorFlow library wasn't compiled to use SSE instructions解决方法
    python安装配置(miniconda版)(Win10+VScode +miniconda)
    Git使用方法
    PDF快速导出为word(免费方法)
    CAJ文件转PDF
    拖拽的效果 第一步 设置 可拖拽的属性 draggable="true" 绑定drag 事件 第二步 设置 放置位置 触发的事件 dragover 第三步 设置 放置之后 触发的事件 dragover 下面请看代码:
  • 原文地址:https://www.cnblogs.com/wuliaokankan/p/10607964.html
Copyright © 2011-2022 走看看