Слияние кода завершено, страница обновится автоматически
#include "WeichatProtoClient.h"
//#include <Common/XSharedArray.h>
//#include <Common/TimeCovert.h>
#include <time.h>
//#include <Common/Log.h>
//#include <Common/json/json.h>
#include <iostream>
#include "json/json.h"
//#include "third/SocketClient.h"
#include "fun.h"
#include "Mytask.h"
#include <fstream>
WeichatProtoClient::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) {
m_iProtocolVer = iProtocolVer;
std::string sslcert = "-----BEGIN CERTIFICATE-----\r\nMIIDqjCCApKgAwIBAgIJAOf7+/avi9foMA0GCSqGSIb3DQEBCwUAMGoxCzAJBgNV\r\nBAYTAkNOMQswCQYDVQQIDAJ4eDELMAkGA1UEBwwCeHgxCzAJBgNVBAoMAnh4MQsw\r\nCQYDVQQLDAJ4eDEUMBIGA1UEAwwLd2VjaGF0QHJvb3QxETAPBgkqhkiG9w0BCQEW\r\nAnh4MB4XDTE4MDUwODAwMzE1MFoXDTI4MDUwNTAwMzE1MFowajELMAkGA1UEBhMC\r\nQ04xCzAJBgNVBAgMAnh4MQswCQYDVQQHDAJ4eDELMAkGA1UECgwCeHgxCzAJBgNV\r\nBAsMAnh4MRQwEgYDVQQDDAt3ZWNoYXRAcm9vdDERMA8GCSqGSIb3DQEJARYCeHgw\r\nggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDNcWVlhOpXjqivCpJpVHCG\r\neM+Q/e83MDpqXmlT33hAFlCfUzWYYhFAHwc+xShkvuoaBwKpAr0fcHT7Kj4TLSJB\r\nF9FwBccPp4Tv0YH0h4pzZ9nWZCMGXB5TlXAreXrcu8Qab0MPAxMKtMO0FZzQawRD\r\nmO/S43u6tDBrhW2zgFzCUo+cRiCYRXoewuFVT4RT7eYvEu579oy4mto7YpR8GfPY\r\nywiTh7D/4To7nNoWbly84WB9ZSQ8HZoC1KTykqaeSGw7xUhKEoPoeKPke1ECfXB2\r\nlSZMwKar2IU0BVlvxL55EMF8oXJozLVEZeVIZ4Wp9EFY2KaZJowgoOa1I+vcwBbd\r\nAgMBAAGjUzBRMB0GA1UdDgQWBBR2SmMGUpTN/Dl0wcSYcPav6o01iDAfBgNVHSME\r\nGDAWgBR2SmMGUpTN/Dl0wcSYcPav6o01iDAPBgNVHRMBAf8EBTADAQH/MA0GCSqG\r\nSIb3DQEBCwUAA4IBAQAdCSkska27VdLcGqK9/sraopxaX31Nseci/sJbimIHxr+q\r\nDwAHExU5sJ1qT827n2OpF/lWMRhnJZ3ubeJ8oGA3CAKu4EiKKGA1hGOLCbEvagCc\r\nsdBSegk050qkMssJzNaw7boZB8vek1RDK32Fuhsh4m+MUZBj6bJCdGW9K+ZMmpZl\r\nbMwmsgqV6+EMvr+PhFHy8bOAdIs4/eOTjW7R0JwYgFArVXMrVKgiRknkhM+PBBHG\r\nDPWO0j3855SF2X5r4jQs2PvKGJjOMuQeIgsf2GbwSQhXEhM8lGdjn9up8hm7VSXf\r\nx8wZquXczPSdDez7tP+g9nKbxcJtGnxo8+Jntmvs\r\n-----END CERTIFICATE-----";
grpc::SslCredentialsOptions ssloption;
ssloption.pem_root_certs = sslcert;
auto channel_creds = grpc::SslCredentials(ssloption);
grpc::ChannelCredentials *channel_cert ;
grpc::ChannelArguments opt;
opt.SetSslTargetNameOverride("wechat@root");
std::shared_ptr<grpc::Channel> channel = grpc::CreateCustomChannel(strTarget, channel_creds, opt);
//std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(strTarget, channel_creds);
m_strAppID = "v1_daya_CodeVip";
m_strAppKey = "v2_3ed426bdc0c56b6a5dac9cef8ff9ba36";
m_strDeviceID = strDeviceID;
m_clientStub = WechatProto::Wechat::NewStub(channel);
m_strDeviceToken = "v3_acf1643387f5e3335cce6a3abbb5b1bf";
m_strWeichatVer = "6.7.2";
// m_pWeixinSocket =
// new SocketClient(("163.177.81.141"), 80); //微信服务器地址 163.177.81.141
m_strLongWeichatServer = "hklong.weixin.qq.com";
m_strShortWeichatServer = "hkshort.weixin.qq.com";
}
WeichatProtoClient::~WeichatProtoClient() {
// delete m_pWeixinSocket;
// if (m_weixinServerThread.joinable())
//{
// m_weixinServerThread.interrupt();
// m_weixinServerThread.join();
//}
delete m_pUser;
}
void WeichatProtoClient::SetWechatNotify(
std::shared_ptr<IWeichatNotify> pCallback, void* pParam) {
m_pWechatNotify = pCallback;
m_pNotifyParam = pParam;
}
int WeichatProtoClient::InitQRCode() {
//获取二维码
WechatProto::WechatMsg getQRCodeReq;
CreateBasicRequest(502, getQRCodeReq);
WechatProto::WechatMsg getQRCodeRsp;
grpc::Status status = HelloWechat(getQRCodeReq, getQRCodeRsp);
printf(getQRCodeReq.DebugString().c_str());
printf(getQRCodeRsp.DebugString().c_str());
if (status.error_code() != grpc::OK) {
printf(("grpc 获取二维码 rsp 失败:%s"),
UTF8_To_string(status.error_message()).c_str());
if (nullptr != m_pWechatNotify) {
m_pWechatNotify->OnError(__LINE__, m_pNotifyParam);
}
return __LINE__;
}
// m_pWeixinSocket->_connect();
// m_weixinServerThread =
// boost::thread(&WeichatProtoClient::DealWeixinServerProc, this);
std::string recvPacket;
if (!SendAndRecvWeichatPacket(getQRCodeRsp, recvPacket)) {
//微信返回出错
printf("微信服务器发包失败");
if (nullptr != m_pWechatNotify) {
m_pWechatNotify->OnError(__LINE__, m_pNotifyParam);
}
return __LINE__;
}
//二维码解包
WechatProto::WechatMsg qrcodeReply;
getQRCodeReq.mutable_basemsg()->set_cmd(-502);
getQRCodeReq.mutable_basemsg()->set_payloads(recvPacket.c_str(),
recvPacket.size());
status = HelloWechat(getQRCodeReq, qrcodeReply);
if (status.error_code() != grpc::OK) {
printf("grpc 解包二维码 失败:%s",
UTF8_To_string(status.error_message()).c_str());
if (nullptr != m_pWechatNotify) {
m_pWechatNotify->OnError(__LINE__, m_pNotifyParam);
}
return __LINE__;
}
// CWechatUtil::dump("获取二维码", getQRCodeRsp,(const byte*)
// recvPacket.c_str(), recvPacket.size(), &qrcodeReply,true);
CWxQrcode result;
if (!CWxQrcode::ParseQrcode(qrcodeReply.basemsg().payloads(), result)) {
std::string strPrint = UTF8_To_string(qrcodeReply.basemsg().payloads());
printf("解析二维码json 数据失败:%s", strPrint.c_str());
if (nullptr != m_pWechatNotify) {
m_pWechatNotify->OnError(__LINE__, m_pNotifyParam);
}
return __LINE__;
}
//通知上层
if (nullptr != m_pWechatNotify) {
m_pWechatNotify->OnQrcodeRsp((const byte*)result._ImgBuf.c_str(),
result._ImgBuf.size(), m_pNotifyParam);
}
std::string strUUID = result._Uuid;
std::string notifyKey = result._NotifyKey;
//循环检测是否有扫描动作
bool bShowHead = false;
int iRet = 0;
while (true) {
if (result._Status == 2) {
m_scanQRCodeInfo = result;
if (nullptr != m_pWechatNotify) {
m_pWechatNotify->OnScanRsp(2, m_scanQRCodeInfo._Username.c_str(),
m_pNotifyParam);
}
break;
} else if (result._Status == 4) {
if (nullptr != m_pWechatNotify) {
m_pWechatNotify->OnScanRsp(4, nullptr, m_pNotifyParam);
}
break;
} else if (result._Status == 0) {
if (nullptr != m_pWechatNotify) {
m_pWechatNotify->OnScanRsp(0, nullptr, m_pNotifyParam);
}
} else if (result._Status == 1) {
if (!bShowHead) {
bShowHead = true;
if (nullptr != m_pWechatNotify) {
m_pWechatNotify->OnScanRsp(1, result._HeadImgUrl.c_str(),
m_pNotifyParam);
}
}
}
//循环检测
WechatProto::WechatMsg CheckQrcodeReq;
CreateBasicRequest(503, CheckQrcodeReq);
CheckQrcodeReq.mutable_basemsg()->set_longhead(
qrcodeReply.basemsg().longhead());
CheckQrcodeReq.mutable_basemsg()->set_payloads(strUUID.c_str(),
strUUID.length());
CheckQrcodeReq.mutable_basemsg()->mutable_user()->set_maxsynckey(
notifyKey.c_str(), notifyKey.size());
WechatProto::WechatMsg CheckQrcodeResp;
status = HelloWechat(CheckQrcodeReq, CheckQrcodeResp);
if (status.error_code() != grpc::OK) {
printf(("grpc 循环检测扫码状态加密包 失败:%s"),
UTF8_To_string(status.error_message()).c_str());
if (nullptr != m_pWechatNotify) {
m_pWechatNotify->OnError(__LINE__, m_pNotifyParam);
}
iRet = __LINE__;
break;
}
std::string recvPacket;
if (!SendAndRecvWeichatPacket(CheckQrcodeResp, recvPacket)) {
//微信返回出错
printf(("给微信服务器发包 失败"));
if (nullptr != m_pWechatNotify) {
m_pWechatNotify->OnError(__LINE__, m_pNotifyParam);
}
iRet = __LINE__;
break;
}
// CWechatUtil::dump(("获取是否扫码"), CheckQrcodeResp, recvPacket.c_str(),
// recvPacket.size(),nullptr,true);
WechatProto::WechatMsg checkScanResp;
CheckQrcodeResp.mutable_basemsg()->set_cmd(-503);
CheckQrcodeResp.mutable_basemsg()->set_payloads(recvPacket.c_str(),
recvPacket.size());
status = HelloWechat(CheckQrcodeResp, checkScanResp);
if (status.error_code() != grpc::OK) {
printf(("grpc 循环检测扫码状态 解密包 失败:%s"),
UTF8_To_string(status.error_message()).c_str());
if (nullptr != m_pWechatNotify) {
m_pWechatNotify->OnError(__LINE__, m_pNotifyParam);
}
iRet = __LINE__;
break;
}
CWxQrcode::ParseQrcode(checkScanResp.basemsg().payloads(), result);
Sleep(500);
}
return iRet;
}
int WeichatProtoClient::QRCodeLogin(const std::string strDeviceName,
const std::string& strUUID,
const std::string& strDeviceType) {
Json::Value root;
root["Username"] = m_scanQRCodeInfo._Username;
root["PassWord"] = m_scanQRCodeInfo._Password;
root["UUid"] = strUUID;
root["DeviceName"] = strDeviceName;
root["DeviceType"] = strDeviceType;
root["ProtocolVer"] = m_iProtocolVer;
WechatProto::WechatMsg QrcodeLoginReq;
CreateBasicRequest(1111, QrcodeLoginReq);
QrcodeLoginReq.mutable_basemsg()->set_payloads(root.toStyledString());
WechatProto::WechatMsg QrcodeLoginRsp;
grpc::Status status = HelloWechat(QrcodeLoginReq, QrcodeLoginRsp);
if (status.error_code() != grpc::OK) {
printf(("grpc 发送登陆包的时候 加密包 失败:%s"),
UTF8_To_string(status.error_message()).c_str());
return __LINE__;
}
std::string recvPacket;
if (!SendAndRecvWeichatPacket(QrcodeLoginRsp, recvPacket)) {
printf(("微信服务器发包失败"));
return __LINE__;
}
//解包
WechatProto::WechatMsg QrcodeLoginRsp2;
CreateBasicRequest(-1001, QrcodeLoginRsp2);
QrcodeLoginRsp2.mutable_basemsg()->set_payloads(recvPacket.c_str(),
recvPacket.size());
WechatProto::WechatMsg checkLoginResp;
status = HelloWechat(QrcodeLoginRsp2, checkLoginResp);
if (status.error_code() != grpc::OK) {
printf(("grpc 循环检测扫码状态 解密包 失败:%s"),
UTF8_To_string(status.error_message()).c_str());
return __LINE__;
}
// CWechatUtil::dump(("发送登陆消息"), QrcodeLoginRsp, recvPacket.c_str(),
// recvPacket.size(), &checkLoginResp,true);
if (checkLoginResp.basemsg().ret() == -301) {
m_strLongWeichatServer = checkLoginResp.basemsg().longhost();
m_strShortWeichatServer = checkLoginResp.basemsg().shorthost();
printf(("重定向什么鬼"));
//delete m_pWeixinSocket;
// if (m_weixinServerThread.joinable())
//{
// m_weixinServerThread.interrupt();
// m_weixinServerThread.join();
//}
// m_pWeixinSocket =
// new SocketClient(UTF8_To_string(checkLoginResp.basemsg().longhost()),
// 80); //微信服务器地址
// m_pWeixinSocket->_connect();
// m_weixinServerThread =
//boost::thread(&WeichatProtoClient::DealWeixinServerProc, this);
return __LINE__;
}
if (checkLoginResp.basemsg().ret() == 0) {
m_strLongWeichatServer = checkLoginResp.basemsg().longhost();
m_strShortWeichatServer = checkLoginResp.basemsg().shorthost();
m_pUser = new WechatProto::User;
InterSaveConfig();
*m_pUser = checkLoginResp.basemsg().user();
return 0;
}
return checkLoginResp.basemsg().ret();
}
int WeichatProtoClient::NewInit() {
int iIndex = 0;
while (true) {
WechatProto::WechatMsg NewinitReq;
CreateBasicRequest(1002, NewinitReq);
WechatProto::WechatMsg NewinitReqRsp;
grpc::Status status = HelloWechat(NewinitReq, NewinitReqRsp);
if (status.error_code() != grpc::OK) {
printf(("grpc 发送NewInit 的时候 加密包 失败:%s"),
UTF8_To_string(status.error_message()).c_str());
return __LINE__;
}
std::string recvPacket;
if (!SendAndRecvWeichatPacket(NewinitReqRsp, recvPacket)) {
printf(("微信服务器发包失败"));
return __LINE__;
}
WechatProto::WechatMsg NewInitDecReq;
CreateBasicRequest(-1002, NewInitDecReq);
NewInitDecReq.mutable_basemsg()->set_payloads(recvPacket.c_str(),
recvPacket.size());
WechatProto::WechatMsg NewInitDecRsp;
status = HelloWechat(NewInitDecReq, NewInitDecRsp);
if (status.error_code() != grpc::OK) {
printf(("grpc 发送NewInit 的时候 加密包 失败:%s"),
UTF8_To_string(status.error_message()).c_str());
return __LINE__;
}
// CWechatUtil::dump(("登陆之后获取好友_") +
// boost::lexical_cast<std::string>(iIndex), NewinitReqRsp,
// recvPacket.c_str(), recvPacket.size(), &NewInitDecRsp, true);
iIndex++;
if (m_pWechatNotify != nullptr) {
m_pWechatNotify->OnGetContact(NewInitDecRsp.basemsg().payloads().c_str(),
m_pNotifyParam);
}
*m_pUser = NewInitDecRsp.basemsg().user();
if (NewInitDecRsp.basemsg().ret() == 8888) {
break;
}
}
return 0;
}
int WeichatProtoClient::Sync() {
int iIndex = 0;
while (true) {
WechatProto::WechatMsg NewinitReq;
CreateBasicRequest(138, NewinitReq);
WechatProto::WechatMsg NewinitReqRsp;
grpc::Status status = HelloWechat(NewinitReq, NewinitReqRsp);
if (status.error_code() != grpc::OK) {
printf(("grpc 发送 加密包 失败:%s"),
UTF8_To_string(status.error_message()).c_str());
return __LINE__;
}
std::string recvPacket;
if (!SendAndRecvWeichatPacket(NewinitReqRsp, recvPacket)) {
printf(("微信服务器发包失败"));
return __LINE__;
}
WechatProto::WechatMsg NewInitDecReq;
CreateBasicRequest(-138, NewInitDecReq);
NewInitDecReq.mutable_basemsg()->set_payloads(recvPacket.c_str(),
recvPacket.size());
WechatProto::WechatMsg NewInitDecRsp;
status = HelloWechat(NewInitDecReq, NewInitDecRsp);
if (status.error_code() != grpc::OK) {
printf(("grpc 发送NewInit 的时候 加密包 失败:%s"),
UTF8_To_string(status.error_message()).c_str());
return __LINE__;
}
// CWechatUtil::dump(("登陆之后同步_") +
// boost::lexical_cast<std::string>(iIndex), NewinitReqRsp,
// recvPacket.c_str(), recvPacket.size(), &NewInitDecRsp, true);
iIndex++;
if (m_pWechatNotify != nullptr) {
m_pWechatNotify->OnSync(NewInitDecRsp.basemsg().payloads().c_str(),
m_pNotifyParam);
}
*m_pUser = NewInitDecRsp.basemsg().user();
if ((NewInitDecRsp.basemsg().ret() == 8888) ||
(NewInitDecRsp.basemsg().payloads() == "null")) {
break;
}
}
return 0;
}
grpc::Status WeichatProtoClient::HelloWechat(const WechatProto::WechatMsg& request, WechatProto::WechatMsg& response)
{
grpc::Status status;
for (int i = 0; i < 3; i++) {
grpc::ClientContext clientContext;
clientContext.AddMetadata("appid", "v1_daya_CodeVip");
clientContext.AddMetadata("appkey", "v2_3ed426bdc0c56b6a5dac9cef8ff9ba36");
status = m_clientStub->HelloWechat(&clientContext, request, &response);
if (status.error_code() == grpc::OK) {
break;
}
Sleep(300);
}
return status;
}
std::string WeichatProtoClient::UserLogin(const std::string& username,
const std::string& password)
{
Json::Value root;
root["Username"] = username;
root["PassWord"] = password;
root["UUid"] = "567D18B2-BCE3-4AA2-9ED1-1FDC19446568";
root["DeviceType"] =
"<k21>TP_lINKS_6G</k21><k22>中国移动</k22><k24>c2:cd:3d:1c:5b:12</k24>";
root["DeviceName"] = "JackyiPad";
root["ProtocolVer"] = 1;
std::string rsq;
InterSendShortCommand(root.toStyledString(), 2222, -2222, rsq);
return rsq;
}
void WeichatProtoClient::CreateBasicRequest(int iCmd,
WechatProto::WechatMsg& request) {
//基本信息
request.set_token(m_strDeviceToken);
request.set_version(m_strWeichatVer);
request.set_timestamp((int)time(NULL));
request.set_ip("223.104.254.91");
// basesic 信息
WechatProto::BaseMsg* pBase = new WechatProto::BaseMsg;
pBase->set_cmd(iCmd);
Json::Value root;
root["ProtocolVer"] = m_iProtocolVer;
pBase->set_payloads(root.toStyledString());
WechatProto::User* pUser = pBase->mutable_user();
if (m_pUser != nullptr) {
//直接赋值
*pUser = *m_pUser;
} else {
/************************************************************************/
/* pUser->set_deviceid("507580550237B47E8D5DB9DC708E0F80");
byte RandomEncryKey[] = { 80, 117, 128, 85, 2, 55, 180, 126, 141, 93, 185,
220, 112, 142, 15, 128 }; pUser->set_sessionkey(RandomEncryKey,
sizeof(RandomEncryKey) / sizeof(byte));
*/
/************************************************************************/
pUser->set_deviceid(m_strDeviceID);
byte RandomEncryKey[] = {80, 117, 128, 85, 2, 55, 180, 126,
141, 93, 185, 220, 112, 142, 15, 128};
pUser->set_sessionkey(RandomEncryKey,
sizeof(RandomEncryKey) / sizeof(byte));
}
request.set_allocated_basemsg(pBase);
}
void WeichatProtoClient::SendWeichatData(const byte* buffer, int iBufferLen) {
//m_pWeixinSocket->_send(std::string((char*)buffer, iBufferLen));
}
int WeichatProtoClient::SendWeichatPacket(WechatProto::WechatMsg& packet) {
std::string sendBuffer;
sendBuffer.resize(packet.basemsg().longhead().length() +
packet.basemsg().payloads().length());
memcpy((void*)sendBuffer.c_str(), packet.basemsg().longhead().c_str(), 16);
memcpy((void*)sendBuffer.c_str(), packet.basemsg().payloads().c_str(),
packet.basemsg().payloads().length());
int iSerial = *(int*)(sendBuffer.c_str() + 12);
iSerial = ntohl(iSerial);
SendWeichatData((const unsigned char*)sendBuffer.c_str(), sendBuffer.size());
return iSerial;
}
bool WeichatProtoClient::GetPacket(int iSeq, std::string& packet) {
std::lock_guard<std::mutex> lock(m_recvMutex);
std::map<int, std::string>::iterator it = m_recvPacketMap.find(iSeq);
if (it == m_recvPacketMap.end()) {
return false;
}
packet = it->second;
m_recvPacketMap.erase(it);
return true;
}
bool WeichatProtoClient::SendAndRecvWeichatPacket(
WechatProto::WechatMsg& packet, std::string& recvPacket) {
int iSerial = SendWeichatPacket(packet);
for (int i = 0; i < 50; i++) {
Sleep(100);
if (GetPacket(iSerial, recvPacket)) {
break;
}
}
if (recvPacket.size() == 0) {
return false;
}
if (recvPacket.c_str()[16] != 191) {
//微信返回出错
return false;
}
return true;
}
int WeichatProtoClient::AutoAuthLogin(const std::string& strUUID,
const std::string& strDeviceType,
std::string& strResult) {
InterReloadConfig();
Json::Value root;
root["UUid"] = strUUID;
root["DeviceType"] = strDeviceType;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 702, -702, strResult);
}
int WeichatProtoClient::GetContact(const std::string& strUserNameLists,
std::string& strResult) {
Json::Value root;
root["UserNameList"] = strUserNameLists;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 182, -182, strResult);
}
int WeichatProtoClient::SyncCheck() {
WechatProto::WechatMsg commandReq;
CreateBasicRequest(205, commandReq);
WechatProto::WechatMsg commandRsp;
grpc::Status status = HelloWechat(commandReq, commandRsp);
if (status.error_code() != grpc::OK) {
printf(("grpc 发送登陆包的时候 加密包 失败:%s"),
UTF8_To_string(status.error_message()).c_str());
return __LINE__;
}
std::string recvPacket;
if (!SendAndRecvWeichatPacket(commandRsp, recvPacket)) {
printf(("微信服务器发包失败"));
return __LINE__;
}
return 0;
}
int WeichatProtoClient::SearchContact(const std::string& strUserName,
std::string& strResult) {
Json::Value root;
root["Username"] = strUserName;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 106, -106, strResult);
}
int WeichatProtoClient::InterSendCommand(const std::string& strPayload,
int iEncCommand, int iDecCommand,
std::string& strResult) {
return 0;
}
int WeichatProtoClient::InterSendShortCommand(const std::string& strPayload,
int iEncCommand, int iDecCommand,
std::string& strResult) {
WechatProto::WechatMsg commandReq;
CreateBasicRequest(iEncCommand, commandReq);
commandReq.mutable_basemsg()->set_payloads(strPayload);
WechatProto::WechatMsg commandRsp;
grpc::Status status = HelloWechat(commandReq, commandRsp);
if (status.error_code() != grpc::OK) {
printf(("grpc 发送登陆包的时候 加密包 失败:%s"),
UTF8_To_string(status.error_message()).c_str());
return __LINE__;
}
// http post 上传
std::string strURL = m_strShortWeichatServer + commandRsp.basemsg().cmdurl();
printf(commandRsp.DebugString().c_str());
std::string strResponse = mm_post(nullptr,m_strShortWeichatServer, strURL,
commandRsp.basemsg().payloads());
// CNetUtils::HttpRequest(UTF8_To_string(strURL),
// commandRsp.basemsg().payloads(), strResponse);
if (strResponse.length() < 1) {
return __LINE__;
}
if ((byte)strResponse.c_str()[0] != 191) {
return __LINE__;
}
/* WechatProto::WechatMsg commandDecReq;
CreateBasicRequest(iDecCommand, commandDecReq);
commandDecReq.mutable_basemsg()->set_payloads(strResponse.c_str(),
strResponse.length());
WechatProto::WechatMsg commandDecRsp;
status = HelloWechat(commandDecReq, commandDecRsp);
printf(commandDecRsp.DebugString().c_str());
if (status.error_code() != grpc::OK) {
printf(("grpc 循环检测扫码状态 解密包 失败:%s"),
UTF8_To_string(status.error_message()).c_str());
return __LINE__;
}*/
// CWechatUtil::dump(("短连接命令_") +
// boost::lexical_cast<std::string>(iEncCommand), commandRsp, (const
// byte*)strResponse.c_str(), strResponse.length(), &commandDecRsp, false);
//*m_pUser = commandDecRsp.basemsg().user();
//strResult = commandDecRsp.basemsg().payloads();
return 0;
}
void WeichatProtoClient::InterSaveConfig() {}
void WeichatProtoClient::InterReloadConfig() {}
int WeichatProtoClient::Oplog(const std::string& strUserName, int iOpt,
const std::string& strRemarkName,
std::string& strResult) {
Json::Value root;
root["Cmdid"] = 2;
root["CmdBuf"] = strUserName;
root["BitVal"] = iOpt;
root["Remark"] = strRemarkName;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendShortCommand(root.toStyledString(), 681, -681, strResult);
}
int WeichatProtoClient::GetA8Key(const std::string& strUrl, int iSence,
const std::string& strUserName,
std::string& strResult) {
Json::Value root;
root["ReqUrl"] = strUrl;
root["Scene"] = iSence;
root["Username"] = strUserName;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 233, -233, strResult);
}
int WeichatProtoClient::CreatHongBaoReq(int iHongType, int iHongbaoFrom,
const std::string& strToUser,
int iCount, int iTotalAmount,
const std::string& strContent,
std::string& strResult) {
Json::Value root;
root["CgiCmd"] = 1;
root["HBType"] = iHongType;
root["HBFrom"] = iHongbaoFrom;
root["ToUsername"] = strToUser;
root["Count"] = iCount;
root["TotalAmount"] = iTotalAmount;
root["HBContent"] = strContent;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendShortCommand(root.toStyledString(), 385, -385, strResult);
}
int WeichatProtoClient::TenPayRequest(const std::string& strReqKey,
const std::string& strPasswd,
std::string& strResult) {
Json::Value root;
root["CgiCmd"] = 0;
root["ReqKey"] = strReqKey;
root["PassWord"] = strPasswd;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 385, -385, strResult);
}
int WeichatProtoClient::OpenHB(int iAction, const std::string& strFromUser,
const std::string& strNativeurl, int iPage,
const std::string& strTimingIdentifier,
std::string& strResult) {
Json::Value root;
root["CgiCmd"] = iAction;
root["FromUserName"] = strFromUser;
root["Nativeurl"] = strNativeurl;
root["Limit"] = iPage;
root["TimingIdentifier"] = strTimingIdentifier;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendShortCommand(root.toStyledString(), 1556, -1556, strResult);
}
int WeichatProtoClient::Paysns(const std::string& strReqKey,
const std::string& strPasswd,
std::string& strResult) {
Json::Value root;
root["CgiCmd"] = 1664;
root["ReqKey"] = strReqKey;
root["PassWord"] = strPasswd;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendShortCommand(root.toStyledString(), 385, -385, strResult);
}
int WeichatProtoClient::Sharewxhb(const std::string& strSendID,
const std::string& strToUserName,
std::string& strResult) {
Json::Value root;
root["CgiCmd"] = 1668;
root["SendId"] = strSendID;
root["ToUsername"] = strToUserName;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendShortCommand(root.toStyledString(), 385, -385, strResult);
}
int WeichatProtoClient::GenPreTransferReq(const std::string& strToUser,
int iTotalAmount,
const std::string& strContent,
std::string& strResult) {
Json::Value root;
root["CgiCmd"] = 83;
root["Desc"] = strContent;
root["ToUsername"] = strToUser;
root["Count"] = iTotalAmount;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendShortCommand(root.toStyledString(), 385, -385, strResult);
}
int WeichatProtoClient::TransferReq(const std::string& strReqKey,
const std::string& strPasswd,
std::string& strResult) {
Json::Value root;
root["CgiCmd"] = 0;
root["ReqKey"] = strReqKey;
root["PassWord"] = strPasswd;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 385, -385, strResult);
}
int WeichatProtoClient::SendCardMsg(const std::string& strToUser,
const std::string& strContent,
const std::string& strAtUser,
std::string& strResult) {
Json::Value root;
root["ToUserName"] = strToUser;
root["Content"] = strContent;
root["Type"] = 42;
root["MsgSource"] = strAtUser;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 522, -522, strResult);
}
int WeichatProtoClient::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) {
Json::Value root;
root["ToUserName"] = strToUser;
root["ClientImgId"] = strClientImgId;
root["StartPos"] = 0;
root["TotalLen"] = iTotalLen;
root["DataLen"] = iTotalLen;
root["CDNMidImgUrl"] = strCDNMidImgUrl;
root["AESKey"] = strAESKey;
root["CDNMidImgSize"] = iTotalLen;
root["CDNThumbImgSize"] = iCDNThumbImgSize;
root["CDNThumbImgWidth"] = iCDNThumbImgWidth;
root["CDNThumbImgHeight"] = iCDNThumbImgHeight;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 110, -110, strResult);
}
int WeichatProtoClient::CreateChatRoom(const std::string& strMemberLists,
std::string& strResult) {
Json::Value root;
root["Membernames"] = strMemberLists;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 119, -119, strResult);
}
int WeichatProtoClient::AddChatRoomMember(const std::string& strRoomID,
const std::string& strMemberLists,
std::string& strResult) {
Json::Value root;
root["Roomeid"] = strRoomID;
root["Membernames"] = strMemberLists;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 120, -120, strResult);
}
int WeichatProtoClient::InviteChatroomUser(const std::string& strRoomID,
const std::string& strMember,
std::string& strResult) {
Json::Value root;
root["ChatRoom"] = strRoomID;
root["Username"] = strMember;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendShortCommand(root.toStyledString(), 610, -610, strResult);
}
int WeichatProtoClient::DelChatRoomUser(const std::string& strRoomID,
const std::string& strMember,
std::string& strResult) {
Json::Value root;
root["ChatRoom"] = strRoomID;
root["Username"] = strMember;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendShortCommand(root.toStyledString(), 179, -179, strResult);
}
int WeichatProtoClient::GetRoomDetail(const std::string& strRoomID,
std::string& strResult) {
Json::Value root;
root["ChatRoom"] = strRoomID;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendShortCommand(root.toStyledString(), 551, -551, strResult);
}
int WeichatProtoClient::ModChatroomname(const std::string& strRoomID,
const std::string& strRoomName,
std::string& strResult) {
Json::Value root;
root["Cmdid"] = 27;
root["ChatRoom"] = strRoomID;
root["Roomname"] = strRoomName;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendShortCommand(root.toStyledString(), 681, -681, strResult);
}
int WeichatProtoClient::AddUser(const std::string& strEncryptusername,
const std::string& strTicket,
const std::string& strContent, int iScene,
std::string& strResult) {
Json::Value root;
root["Encryptusername"] = strEncryptusername;
root["Ticket"] = strTicket;
root["Type"] = 2;
root["Content"] = strContent;
root["Sence"] = iScene;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 137, -137, strResult);
}
int WeichatProtoClient::AcceptUser(const std::string& strEncryptusername,
const std::string& strTicket,
const std::string& strContent,
std::string& strResult) {
Json::Value root;
root["Encryptusername"] = strEncryptusername;
root["Ticket"] = strTicket;
root["Type"] = 3;
root["Content"] = strContent;
root["Sence"] = 14;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 137, -137, strResult);
}
int WeichatProtoClient::SayHello(const std::string& strEncryptusername,
const std::string& strTicket,
const std::string& strContent,
std::string& strResult) {
return AddUser(strEncryptusername, strTicket, strContent, 18, strResult);
}
int WeichatProtoClient::Attention(const std::string& strEncryptusername,
std::string& strResult) {
Json::Value root;
root["Encryptusername"] = strEncryptusername;
root["Ticket"] = std::string("");
root["Type"] = 1;
root["Content"] = std::string("");
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 137, -137, strResult);
}
int WeichatProtoClient::DelUser(const std::string& strUserName,
std::string& strResult) {
Json::Value root;
root["Cmdid"] = 7;
root["CmdBuf"] = strUserName;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendShortCommand(root.toStyledString(), 681, -681, strResult);
}
int WeichatProtoClient::MassSendText(const std::string& strUserName,
const std::string& strContent,
std::string& strResult) {
// Json::Value root;
// root["ToList"] = strUserName;
// root["ToListMd5"] = CCryptUtil::MD5(strUserName);
// root["DataStartPos"] = 0;
// root["DataTotalLen"] = (int)strContent.length();
// std::string strBase64Content;
// CCryptUtil::Base64Encoder(strContent, strBase64Content);
// root["DataBuffer"] = strBase64Content;
// root["MsgType"] = 1;
// root["VoiceFormat"] = 0;
// root["ClientId"] =
// CCryptUtil::MD5(boost::lexical_cast<std::string>(CTimeCovert::CurrentTimeToiTunesTimeSpan_1970(0)));
// root["ProtocolVer"] = m_iProtocolVer;
return 0;
}
int WeichatProtoClient::MassSendVoice(const std::string& strUserName,
const std::string& strFilePath,
int iVoiceFormat,
std::string& strResult) {
// CXFile file;
// if (XErrorcode_Success != file.LoadFile(UTF8_To_string(strFilePath),
// CXFile::Mode_OpenExist))
//{
// return __LINE__;
//}
// int iFileSize = (int)file.GetFileSize();
// boost::shared_array<byte> buffer(new byte[iFileSize]);
// file.Read(buffer.c_str(), iFileSize);
std::string base64FileContent;
// CCryptUtil::Base64Encoder(buffer.c_str(), iFileSize, base64FileContent);
Json::Value root;
// root["ToList"] = strUserName;
// root["ToListMd5"] = CCryptUtil::MD5(strUserName);
// root["DataStartPos"] = 0;
// root["DataTotalLen"] = iFileSize;
// root["DataBuffer"] = base64FileContent;
// root["MsgType"] = 34;
// root["VoiceFormat"] = iVoiceFormat;
// root["ClientId"] =
// CCryptUtil::MD5(boost::lexical_cast<std::string>(CTimeCovert::CurrentTimeToiTunesTimeSpan_1970(0)));
// root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 193, -193, strResult);
}
int WeichatProtoClient::MassSendImage(const std::string& strUserName,
const std::string& strFilePath,
std::string& strResult) {
// CXFile file;
// if (XErrorcode_Success != file.LoadFile(UTF8_To_string(strFilePath),
// CXFile::Mode_OpenExist))
//{
// return __LINE__;
//}
// int iFileSize = (int)file.GetFileSize();
// std::string strClientImgId = m_pUser->userame() +
// boost::lexical_cast<std::string>((int)CTimeCovert::CurrentTimeToiTunesTimeSpan_1970(0));
// boost::shared_array<byte> buffer(new byte[65535]);
// int iStartPos = 0;
while (true) {
/* XINT64 iRead = file.Read(buffer.c_str(), 65535);
if (iRead <= 0)
{
break;
}
std::string base64FileContent;
CCryptUtil::Base64Encoder(buffer.c_str(), iRead, base64FileContent);
Json::Value root;
root["ToList"] = strUserName;
root["ToListMd5"] = CCryptUtil::MD5(strUserName);
root["DataStartPos"] = iStartPos;
root["DataTotalLen"] = iFileSize;
root["DataBuffer"] = base64FileContent;
root["MsgType"] = 3;
root["VoiceFormat"] = 0;
root["ClientId"] =
CCryptUtil::MD5(boost::lexical_cast<std::string>(CTimeCovert::CurrentTimeToiTunesTimeSpan_1970(0)));
root["ProtocolVer"] = m_iProtocolVer;*/
// InterSendCommand(root.toStyledString(), 193, -193, strResult);
// iStartPos += (int)iRead;
}
return 0;
}
int WeichatProtoClient::UploadMobileContact(const std::string& strSelfMobile,
const std::string& strMobileLists,
std::string& strResult) {
{
Json::Value root;
root["Opcode"] = 1;
root["Mobile"] = strSelfMobile;
root["MobileList"] = strMobileLists;
std::string strTmpResult;
InterSendShortCommand(root.toStyledString(), 133, -133, strTmpResult);
}
//获取通讯录
{
Json::Value root;
root["Opcode"] = 0;
return InterSendShortCommand(root.toStyledString(), 142, -142, strResult);
}
}
int WeichatProtoClient::AddFrom(int AddFromMobile, int AddFromWechat,
int AddFromChatroom, int AddFromQrcode,
int AddFromCard, std::string& strResult) {
Json::Value root;
root["Cmdid"] = 23;
root["AddFromMobile"] = AddFromMobile;
root["AddFromWechat"] = AddFromWechat;
root["AddFromChatroom"] = AddFromChatroom;
root["AddFromQrcode"] = AddFromQrcode;
root["AddFromCard"] = AddFromCard;
std::string strTmpResult;
return InterSendShortCommand(root.toStyledString(), 681, -681, strResult);
}
int WeichatProtoClient::Logout(std::string& strResult) {
Json::Value root(Json::objectValue);
std::string strTmpResult;
return InterSendShortCommand(root.toStyledString(), 282, -282, strResult);
}
int WeichatProtoClient::ModUserInfo(const std::string& strNickName,
const std::string& strSignature,
const std::string& strCity, int iSex,
std::string& strResult) {
Json::Value root;
root["Cmdid"] = 1;
root["NickName"] = strNickName;
root["Signature"] = strSignature;
root["City"] = strCity;
root["Sex"] = iSex;
std::string strTmpResult;
return InterSendShortCommand(root.toStyledString(), 681, -681, strResult);
}
int WeichatProtoClient::GetLabelList(std::string& strResult) {
Json::Value root(Json::objectValue);
return InterSendShortCommand(root.toStyledString(), 639, -639, strResult);
}
int WeichatProtoClient::AddLabel(const std::string& strLabelName,
std::string& strResult) {
Json::Value root(Json::objectValue);
root["LabelName"] = strLabelName;
return InterSendShortCommand(root.toStyledString(), 635, -635, strResult);
}
int WeichatProtoClient::ModifyLabelList(const std::string& strUserName,
const std::string& strLabelIDS,
std::string& strResult) {
Json::Value root(Json::objectValue);
root["Username"] = strUserName;
root["Labelids"] = strLabelIDS;
return InterSendShortCommand(root.toStyledString(), 638, -638, strResult);
}
int WeichatProtoClient::initcontact(int CurrentWxcontactSeq,
int CurrentChatRoomContactSeq,
std::string& strResult) {
Json::Value root(Json::objectValue);
root["CurrentWxcontactSeq"] = CurrentWxcontactSeq;
root["CurrentChatRoomContactSeq"] = CurrentChatRoomContactSeq;
return InterSendShortCommand(root.toStyledString(), 851, -851, strResult);
}
int WeichatProtoClient::SnsSync(std::string& strResult) {
Json::Value root(Json::objectValue);
return InterSendCommand(root.toStyledString(), 214, -214, strResult);
}
int WeichatProtoClient::SnsUpload(const std::string& strPath,
std::string& strResult) {
// CXFile file;
// if (XErrorcode_Success != file.LoadFile(UTF8_To_string(strPath),
// CXFile::Mode_OpenExist))
//{
// return __LINE__;
//}
// int iFileSize = (int)file.GetFileSize();
// std::string buffer(iFileSize);
// file.Read(buffer.c_str(), iFileSize);
// std::string strBase64Content;
// CCryptUtil::Base64Encoder(buffer.c_str(), iFileSize, strBase64Content);
// std::string strClientImgId = m_pUser->userame() +
// boost::lexical_cast<std::string>((int)CTimeCovert::CurrentTimeToiTunesTimeSpan_1970(0));
// Json::Value root;
// root["StartPos"] = 0;
// root["ClientId"] = strClientImgId;
// root["TotalLen"] = iFileSize;
// root["Uploadbuf"] = strBase64Content;
return 0;
}
int WeichatProtoClient::SnsPost(const std::string& strContent,
std::string& strResult) {
Json::Value root;
root["Content"] = strContent;
return InterSendCommand(root.toStyledString(), 209, -209, strResult);
}
int WeichatProtoClient::SnsUserPage(const std::string& strFirstPageMd5,
const std::string& strUsername, int iMaxID,
std::string& strResult) {
Json::Value root;
root["FirstPageMd5"] = strFirstPageMd5;
root["Username"] = strUsername;
root["MaxId"] = iMaxID;
return InterSendCommand(root.toStyledString(), 212, -212, strResult);
}
int WeichatProtoClient::SnsTimeLine(const std::string& strFirstPageMd5,
int iClientLatestId,
std::string& strResult) {
Json::Value root;
root["FirstPageMd5"] = strFirstPageMd5;
root["ClientLatestId"] = iClientLatestId;
return InterSendCommand(root.toStyledString(), 211, -211, strResult);
}
int WeichatProtoClient::SnsObjectOp(const std::string& strIds, int iType,
std::string& strResult) {
Json::Value root;
root["Ids"] = strIds;
root["Type"] = iType;
return InterSendCommand(root.toStyledString(), 218, -218, strResult);
}
int WeichatProtoClient::SnsComment(const std::string& strId,
const std::string& strToUserName, int iType,
const std::string& Content,
std::string& strResult) {
Json::Value root;
root["ID"] = strId;
root["ToUsername"] = strToUserName;
root["Type"] = iType;
root["Content"] = Content;
return InterSendCommand(root.toStyledString(), 213, -213, strResult);
}
int WeichatProtoClient::wxSendMessage(const std::string& strToUser,
const std::string& strContent,
const std::string& strAtUser,
std::string& strResult) {
Json::Value root(Json::objectValue);
root["ToUserName"] = strToUser;
root["Content"] = strContent;
root["Type"] = 0;
root["MsgSource"] = strAtUser;
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 522, -522, strResult);
}
int WeichatProtoClient::SendAppMsg(const std::string& strToUser,
const std::string& strContent,
const std::string& strAtUser,
std::string& strResult) {
Json::Value root;
root["ToUserName"] = strToUser;
root["Content"] = strContent;
root["Type"] = 5;
root["AppId"] = std::string("");
root["ProtocolVer"] = m_iProtocolVer;
return InterSendCommand(root.toStyledString(), 222, -222, strResult);
}
int WeichatProtoClient::SendImageMsg(const std::string& strToUser,
const std::string& strPath,
std::string& strResult) {
/*CXFile file;
if (XErrorcode_Success != file.LoadFile(UTF8_To_string(strPath),
CXFile::Mode_OpenExist))
{
return __LINE__;
}
int iFileSize = (int)file.GetFileSize();
std::string strClientImgId = m_pUser->userame() +
boost::lexical_cast<std::string>((int)CTimeCovert::CurrentTimeToiTunesTimeSpan_1970(0));
boost::shared_array<byte> buffer(new byte[65535]);
int iStartPos = 0;
while (true)
{
XINT64 iRead = file.Read(buffer.c_str(), 65535);
if (iRead <=0)
{
break;
}
std::string base64FileContent;
CCryptUtil::Base64Encoder(buffer.c_str(), iRead, base64FileContent);
Json::Value root;
root["ClientImgId"] = strClientImgId;
root["ToUserName"] = strToUser;
root["StartPos"] = iStartPos;
root["TotalLen"] = iFileSize;
root["DataLen"] = (int)iRead;
root["Data"] = base64FileContent;
root["ProtocolVer"] = m_iProtocolVer;
InterSendCommand(root.toStyledString(), 110, -110, strResult);
iStartPos += (int)iRead;
}*/
return 0;
}
int WeichatProtoClient::SendVoiceMsg(const std::string& strToUser,
const std::string& strPath,
int iVoiceLength, int iVoiceFormat,
std::string& strResult) {
// CXFile file;
// if (XErrorcode_Success != file.LoadFile(UTF8_To_string(strPath),
//CXFile::Mode_OpenExist))
// {
// return __LINE__;
// }
// int iFileSize = (int)file.GetFileSize();
// boost::shared_array<byte> buffer(new byte[iFileSize]);
// file.Read(buffer.c_str(), iFileSize);
// std::string base64FileContent;
// CCryptUtil::Base64Encoder(buffer.c_str(), iFileSize, base64FileContent);
// Json::Value root;
// root["Offset"] = 0;
// root["ToUserName"] = strToUser;
// root["Length"] = iFileSize;
// root["VoiceLength"] = iVoiceLength;
// root["EndFlag"] = 1;
// root["Data"] = base64FileContent;
// root["VoiceFormat"] = iVoiceFormat;
// root["ProtocolVer"] = m_iProtocolVer;
// return InterSendCommand(root.toStyledString(), 127, -127, strResult);
//}
//
// int WeichatProtoClient::InterSendCommand(const std::string& strPayload, int
// iEncCommand, int iDecCommand, std::string& strResult)
//{
// WechatProto::WechatMsg commandReq;
// CreateBasicRequest(iEncCommand, commandReq);
// commandReq.mutable_basemsg()->set_payloads(strPayload);
//
// WechatProto::WechatMsg commandRsp;
// grpc::Status status = HelloWechat(commandReq, commandRsp);
// if (status.error_code() != grpc::OK)
// {
// printf(("grpc 发送登陆包的时候 加密包 失败:%s"),
//UTF8_To_string(status.error_message()).c_str()); return __LINE__;
// }
//
//
// std::string recvPacket;
// if (!SendAndRecvWeichatPacket(commandRsp, recvPacket))
// {
// printf(("微信服务器发包失败"));
// return __LINE__;
// }
//
// //解包
// WechatProto::WechatMsg commandDecReq;
// CreateBasicRequest(iDecCommand, commandDecReq);
// commandDecReq.mutable_basemsg()->set_payloads(recvPacket.c_str(),
//recvPacket.size());
//
// WechatProto::WechatMsg commandDecRsp;
// status = HelloWechat(commandDecReq, commandDecRsp);
// if (status.error_code() != grpc::OK)
// {
// printf(("grpc 循环检测扫码状态 解密包 失败:%s"),
//UTF8_To_string(status.error_message()).c_str()); return __LINE__;
// }
// //CWechatUtil::dump(("长连接命令_") +
//boost::lexical_cast<std::string>(iEncCommand), commandRsp,
//recvPacket.c_str(), recvPacket.size(), &commandDecRsp,true); *m_pUser =
//commandDecRsp.basemsg().user(); strResult =
//commandDecRsp.basemsg().payloads();
return 0;
}
void WeichatProtoClient::DealWeixinServerProc() {
while (true) {
// boost::this_thread::interruption_point();
std::string packet;
// packet = m_pWeixinSocket->_receive();
if (packet.size() <= 0) {
break;
}
if (packet.size() < 16) {
continue;
}
int iSeq = *(int*)(packet.c_str() + 12);
iSeq = ntohl(iSeq);
{
std::lock_guard<std::mutex> lock(m_recvMutex);
m_recvPacketMap[iSeq] = packet;
}
}
printf(("读取微信数据线程退出了"));
}
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )