Слияние кода завершено, страница обновится автоматически
#pragma once
#include "WechatProto.pb.h"
#include "WechatProto.grpc.pb.h"
#include <grpc++/grpc++.h>
//#include <boost/thread/thread.hpp>
//#include "third/SocketClient.h"
#include "WxQrcode.h"
class IWeichatNotify
{
public:
//h获取到了二维码回调
virtual void OnQrcodeRsp(const unsigned char* buffer,int iBufferLen,void* pParam)=0;
//扫描结果回调0 等待扫描 1 扫描 未确认 可以显示头像 2 扫描并确认 4 取消扫描
virtual void OnScanRsp(int iStatus, const char*pszParam, void* pParam) = 0;
//错误
virtual void OnError(int iErrorCode, void* pParam) = 0;
//同步联系人
virtual void OnGetContact(const char* pszContact, void* pParam) = 0;
//同步资料
virtual void OnSync(const char* pszSyncInfo, void* pParam) = 0;
};
class WeichatProtoClient
{
public:
WeichatProtoClient(int iProtocolVer, const std::string& strTarget, const std::string& strAppID, const std::string& strAppKey, const std::string&strToken, const std::string& strDeviceID, const std::string& strWeichatVer);
~WeichatProtoClient();
void SetWechatNotify(std::shared_ptr<IWeichatNotify> pCallback,void* pParam);
//初始化获取二维码
int InitQRCode();
//登陆
int QRCodeLogin(const std::string strDeviceName, const std::string& strUUID, const std::string& strDeviceType);
//初始化接口
int NewInit();
//同步接口
int Sync();
//二次登陆
int AutoAuthLogin(const std::string& strUUID, const std::string& strDeviceType, std::string& strResult);
//rpc 调用,内部
grpc::Status HelloWechat(const WechatProto::WechatMsg& request, WechatProto::WechatMsg& response);
std::string UserLogin(const std::string& username,
const std::string& password);
//创建一个请求
void CreateBasicRequest(int iCmd, WechatProto::WechatMsg& request);
//给微信服务器发包,直接发数据
void SendWeichatData(const unsigned char* buffer,int iBufferLen);
//发送接收微信服务器回的包
int SendWeichatPacket(WechatProto::WechatMsg& packet);
bool GetPacket(int iSeq, std::string & packet);
//发送并且接收微信服务器回的包
bool SendAndRecvWeichatPacket(WechatProto::WechatMsg& packet, std::string & recvPacket);
//心跳包
int SyncCheck();
//获取联系人
int GetContact(const std::string& strUserNameLists, std::string& strResult);
//搜索联系人
int SearchContact(const std::string& strUserName, std::string& strResult);
//备注,拉黑,星标
//CmdBuf wxid或 @chatroom
//BitVal 2051 保存通讯录 2取消保存通讯录 71 标星 7取消标星 7 备注 15 拉黑 7 取消拉黑
//Remark BitVal=7时 Remark不为空设置备注 为空时取消备注
int Oplog(const std::string& strUserName, int iOpt, const std::string& strRemarkName,std::string& strResult);
//获取A8Key
int GetA8Key(const std::string& strUrl, int iSence, const std::string& strUserName, std::string& strResult);
/************************************************************************/
/* 发红包 */
/************************************************************************/
//创建红包
//0普通红包1拼手气红包
//0 发个人 1发群红包 3分享红包
int CreatHongBaoReq(int iHongType, int iHongbaoFrom, const std::string& strToUser, int iCount, int iTotalAmount, const std::string& strContent,std::string& strResult);
int TenPayRequest(const std::string& strReqKey,const std::string& strPasswd,std::string& strResult);
int OpenHB(int iAction, const std::string& strFromUser, const std::string& strNativeurl, int iPage, const std::string&strTimingIdentifier, std::string& strResult);
//支付分享红包
int Paysns(const std::string& strReqKey, const std::string& strPasswd, std::string& strResult);
int Sharewxhb(const std::string& strSendID, const std::string& strToUserName, std::string& strResult);
//转账
int GenPreTransferReq(const std::string& strToUser, int iTotalAmount, const std::string& strContent, std::string& strResult);
int TransferReq(const std::string& strReqKey, const std::string& strPasswd, std::string& strResult);
//发消息
int wxSendMessage(const std::string&strToUser, const std::string& strContent, const std::string& strAtUser, std::string& strResult);
int SendAppMsg(const std::string&strToUser, const std::string& strContent, const std::string& strAtUser, std::string& strResult);
int SendImageMsg(const std::string&strToUser, const std::string& strPath, std::string& strResult);
//VoiceFormat = 0//0->Arm 无amr音频头 2->MP3 3->WAVE 4->SILK VoiceLength = 1000,//可以自定义语音长度
int SendVoiceMsg(const std::string&strToUser, const std::string& strPath, int iVoiceLength, int iVoiceFormat, std::string& strResult);
int SendCardMsg(const std::string&strToUser, const std::string& strContent, const std::string& strAtUser, std::string& strResult);
int SendCDnimgMsg(const std::string&strToUser, const std::string& strClientImgId, int iTotalLen, const std::string& strCDNMidImgUrl, const std::string& strAESKey, int iCDNThumbImgSize, int iCDNThumbImgHeight, int iCDNThumbImgWidth,std::string& strResult);
//创建群
int CreateChatRoom(const std::string& strMemberLists, std::string& strResult);
int AddChatRoomMember(const std::string& strRoomID, const std::string& strMemberLists, std::string& strResult);
int InviteChatroomUser(const std::string& strRoomID, const std::string& strMember, std::string& strResult);
int DelChatRoomUser(const std::string& strRoomID, const std::string& strMember, std::string& strResult);
int GetRoomDetail(const std::string& strRoomID,std::string& strResult);
int ModChatroomname(const std::string& strRoomID, const std::string& strRoomName, std::string& strResult);
//好友操作
int AddUser(const std::string&strEncryptusername, const std::string& strTicket, const std::string& strContent,int iScene, std::string&strResult);
int AcceptUser(const std::string&strEncryptusername, const std::string& strTicket, const std::string& strContent, std::string&strResult);
int SayHello(const std::string&strEncryptusername, const std::string& strTicket, const std::string& strContent, std::string&strResult);
int Attention(const std::string&strEncryptusername, std::string&strResult);
//wxid
int DelUser(const std::string&strUserName, std::string&strResult);
//群发接口
//多微信wxid 分号分割如 wxid1;wxid2;wxid3;
int MassSendText(const std::string&strUserName, const std::string& strContent,std::string& strResult);
int MassSendVoice(const std::string&strUserName, const std::string& strFilePath, int iVoiceFormat, std::string& strResult);
int MassSendImage(const std::string&strUserName, const std::string& strFilePath, std::string& strResult);
//通讯录
int UploadMobileContact(const std::string& strSelfMobile, const std::string& strMobileLists, std::string& strResult);
int AddFrom(int AddFromMobile, int AddFromWechat, int AddFromChatroom, int AddFromQrcode, int AddFromCard,std::string& strResult);
int Logout(std::string& strResult);
int ModUserInfo(const std::string& strNickName,const std::string& strSignature,const std::string& strCity, int iSex, std::string& strResult);
//标签
int GetLabelList(std::string& strResult);
int AddLabel(const std::string& strLabelName,std::string& strResult);
int ModifyLabelList(const std::string&strUserName, const std::string& strLabelIDS, std::string& strResult);
int initcontact(int CurrentWxcontactSeq, int CurrentChatRoomContactSeq, std::string& strResult);
//朋友圈
int SnsSync(std::string& strResult);
int SnsUpload(const std::string&strPath, std::string& strResult);
int SnsPost(const std::string& strContent, std::string& strResult);
int SnsUserPage(const std::string&strFirstPageMd5, const std::string& strUsername, int iMaxID, std::string& strResult);
int SnsTimeLine(const std::string&strFirstPageMd5, int iClientLatestId, std::string& strResult);
int SnsObjectOp(const std::string&strIds, int iType, std::string& strResult);
int SnsComment(const std::string&strId, const std::string& strToUserName, int iType, const std::string& Content, std::string& strResult);
private:
int InterSendCommand(const std::string& strPayload, int iEncCommand, int iDecCommand, std::string& strResult);
int InterSendShortCommand(const std::string& strPayload, int iEncCommand, int iDecCommand, std::string& strResult);
void InterSaveConfig();
void InterReloadConfig();
std::unique_ptr<WechatProto::Wechat::Stub> m_clientStub;
std::string m_strDeviceToken;
std::string m_strWeichatVer;
std::string m_strDeviceID;
std::string m_strAppID;
std::string m_strAppKey;
WechatProto::User* m_pUser=nullptr;
//和微信服务器建立的连接
//SocketClient* m_pWeixinSocket=nullptr;
//boost::thread m_weixinServerThread;
void DealWeixinServerProc();
std::map<int, std::string>m_recvPacketMap;
std::mutex m_recvMutex;
//通知回调
std::shared_ptr<IWeichatNotify> m_pWechatNotify;
void* m_pNotifyParam=nullptr;
//扫描的二维码
CWxQrcode m_scanQRCodeInfo;
//长连接,端连接域名
std::string m_strLongWeichatServer;
std::string m_strShortWeichatServer;
int m_iProtocolVer;
};
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )