uwp移植http网络模块遇到的问题

引擎版本:cocos2dx 3.8+一,网络模块,接到任务的一般顺序1,对照接口文档,列出技术储备;2,对应技术储备列表,找出相关技术;3,写出demo,联调接口;4,检查逻辑,完善代码。
二,一些简单思绪短链接,长链接?http协议数据传输格式?json,xml数据编码?base64数据加密?md5
三,遇到的问题和具体解决方法1,HttpRequest头的设置先上代码: HttpRequest* request = new (std::nothrow) HttpRequest();
request->setUrl(ApiUtils::UserLoginUrl.c_str());
request->setRequestType(HttpRequest::Type::POST);
request->setResponseCallback(CC_CALLBACK_2(LoginScene::onHttpRequestCompletedLogin, this));

std::string postData;
ApiUtils::getInstance()->setQuickLogin(postData);


std::vector<std::string> headers;
headers.push_back("Content-Type: application/x-www-form-urlencoded; charset=utf-8");
request->setHeaders(headers);
request->setRequestData(postData.c_str(), strlen(postData.c_str()));
request->setTag("QuickLogin");
HttpClient::getInstance()->send(request);
request->release();

再说说遇到的问题:原来写的代码原本参考,官网给出的代码,没有加下面这句话 std::vectorstd::string headers; headers.push_back(“Content-Type: application/x-www-form-urlencoded; charset=utf-8”); request->setHeaders(headers);问题在于,在win32,android平台下,网络接口正常;但是在uwp上面,服务器反馈的结果就是参数为空。这个问题困扰我很久,把源码中所有的接口都看了一遍,然后看到有一个headers的设置,还有跟我对接的服务端(php)提示我说,我看php请求,都加了数据请求的类型。我想这两个应该能够对上。查了相关的资料,这个问题还真解决了。
http://blog.csdn.net/blueheart20/article/details/45174399
这个链接里面的类型比较全。
2,Base64编码和解码先上代码:std::string Config::base64_encode(const std::string& strTemp)
{
std::string dst = “”;

int len = 0;
char *buffer;
len = base64Encode((unsigned char*)strTemp.c_str(), (unsigned int)strTemp.length(), &buffer);
for (int i = 0; i < len; i++)
{
    dst += buffer*;*
    • }

    return dst;
    }

std::string Config::base64_decode(const std::string& strTemp)
{
std::string dst = “”;

int len = 0;
unsigned char *buffer;
len = base64Decode((unsigned char*)strTemp.c_str(), (unsigned int)strTemp.length(), &buffer);
for (int i = 0; i < len; i++)
{
    dst += buffer;
}


return dst;

}

再说说遇到的问题:现在打代码比较懒,喜欢在引擎内部找,果然就找到了base64的方法。
3,rapidjson,字符串组装的改变 rapidjson::Document writedoc;
writedoc.SetObject();
rapidjson::Document::AllocatorType& allocator = writedoc.GetAllocator();

rapidjson::Value userValue(username.c_str(), allocator);
writedoc.AddMember("un", userValue, allocator);

记得之前的版本只需要这么写:writedoc.AddMember(“un”, username.c_str(),allocator);

:2::2::2::2::2:

HttpRequest并没有你写的设置,搜索到的是void SIOClientImpl::handshake()
{
CCLOGINFO(“SIOClientImpl::handshake() called”);

std::stringstream pre;
pre << "http://" << _uri << "/socket.io/1/?EIO=2&transport=polling&b64=true";

HttpRequest* request = new (std::nothrow) HttpRequest();
request->setUrl(pre.str().c_str());
request->setRequestType(HttpRequest::Type::GET);

request->setResponseCallback(CC_CALLBACK_2(SIOClientImpl::handshakeResponse, this));
request->setTag("handshake");

CCLOGINFO("SIOClientImpl::handshake() waiting");

HttpClient::getInstance()->send(request);

request->release();


return;

}
请问如何修改

你这是2.x版本的引擎吧。你现在遇到了什么问题,需要达到的功能是怎样的?

这几天在忙别的功能,没看竟然有回复了~~~!!!太感谢,http://www.cocoachina.com/bbs/read.php?tid-455449-keyword-uwp.html,根据这个工程做的lua的uwp移植,版本应该是3.10的,但是无法获得服务器反馈,需求,正常获取网络通信服务,另外还想问下,uwp的横版和竖版怎么调整的?在
OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) :
mOpenGLES(openGLES),
mRenderSurface(EGL_NO_SURFACE),
mCoreInput(nullptr),
mDpi(0.0f),
mDeviceLost(false),
mCursorVisible(true),
mVisible(false),
mOrientation(DisplayOrientations::Landscape)
{
调整并没有什么用处