websocket默认读取ssl证书
This commit is contained in:
parent
a642639485
commit
21b8354194
@ -262,7 +262,7 @@ void JSB_WebSocketDelegate::setJSDelegate(const se::Value& jsDelegate)
|
|||||||
|
|
||||||
static bool WebSocket_finalize(se::State& s)
|
static bool WebSocket_finalize(se::State& s)
|
||||||
{
|
{
|
||||||
WebSocket* cobj = (WebSocket*)s.nativeThisObject();
|
auto* cobj = (WebSocket*)s.nativeThisObject();
|
||||||
CCLOGINFO("jsbindings: finalizing JS object %p (WebSocket)", cobj);
|
CCLOGINFO("jsbindings: finalizing JS object %p (WebSocket)", cobj);
|
||||||
|
|
||||||
// Manually close if web socket is not closed
|
// Manually close if web socket is not closed
|
||||||
@ -334,7 +334,7 @@ static bool WebSocket_constructor(se::State& s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cobj = new (std::nothrow) WebSocket();
|
cobj = new (std::nothrow) WebSocket();
|
||||||
JSB_WebSocketDelegate* delegate = new (std::nothrow) JSB_WebSocketDelegate();
|
auto* delegate = new (std::nothrow) JSB_WebSocketDelegate();
|
||||||
if (cobj->init(*delegate, url, &protocols, caFilePath))
|
if (cobj->init(*delegate, url, &protocols, caFilePath))
|
||||||
{
|
{
|
||||||
delegate->setJSDelegate(se::Value(obj, true));
|
delegate->setJSDelegate(se::Value(obj, true));
|
||||||
@ -352,8 +352,9 @@ static bool WebSocket_constructor(se::State& s)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
cobj = new (std::nothrow) WebSocket();
|
cobj = new (std::nothrow) WebSocket();
|
||||||
JSB_WebSocketDelegate* delegate = new (std::nothrow) JSB_WebSocketDelegate();
|
std::string caFilePath = "cacert.pem";
|
||||||
if (cobj->init(*delegate, url))
|
auto* delegate = new (std::nothrow) JSB_WebSocketDelegate();
|
||||||
|
if (cobj->init(*delegate, url, nullptr, caFilePath))
|
||||||
{
|
{
|
||||||
delegate->setJSDelegate(se::Value(obj, true));
|
delegate->setJSDelegate(se::Value(obj, true));
|
||||||
cobj->retain(); // release in finalize function and onClose delegate method
|
cobj->retain(); // release in finalize function and onClose delegate method
|
||||||
@ -395,8 +396,8 @@ static bool WebSocket_send(se::State& s)
|
|||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
WebSocket* cobj = (WebSocket*)s.nativeThisObject();
|
auto* cobj = (WebSocket*)s.nativeThisObject();
|
||||||
bool ok = false;
|
bool ok;
|
||||||
if (args[0].isString())
|
if (args[0].isString())
|
||||||
{
|
{
|
||||||
std::string data;
|
std::string data;
|
||||||
@ -452,7 +453,7 @@ static bool WebSocket_close(se::State& s)
|
|||||||
const auto& args = s.args();
|
const auto& args = s.args();
|
||||||
int argc = (int)args.size();
|
int argc = (int)args.size();
|
||||||
|
|
||||||
WebSocket* cobj = (WebSocket*)s.nativeThisObject();
|
auto* cobj = (WebSocket*)s.nativeThisObject();
|
||||||
if(argc == 0)
|
if(argc == 0)
|
||||||
{
|
{
|
||||||
cobj->closeAsync();
|
cobj->closeAsync();
|
||||||
@ -510,7 +511,7 @@ static bool WebSocket_getReadyState(se::State& s)
|
|||||||
|
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
{
|
{
|
||||||
WebSocket* cobj = (WebSocket*)s.nativeThisObject();
|
auto* cobj = (WebSocket*)s.nativeThisObject();
|
||||||
s.rval().setInt32((int)cobj->getReadyState());
|
s.rval().setInt32((int)cobj->getReadyState());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -526,7 +527,7 @@ static bool WebSocket_getBufferedAmount(se::State& s)
|
|||||||
|
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
{
|
{
|
||||||
WebSocket* cobj = (WebSocket*)s.nativeThisObject();
|
auto* cobj = (WebSocket*)s.nativeThisObject();
|
||||||
s.rval().setUint32((uint32_t)cobj->getBufferedAmount());
|
s.rval().setUint32((uint32_t)cobj->getBufferedAmount());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -542,7 +543,7 @@ static bool WebSocket_getExtensions(se::State& s)
|
|||||||
|
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
{
|
{
|
||||||
WebSocket* cobj = (WebSocket*)s.nativeThisObject();
|
auto* cobj = (WebSocket*)s.nativeThisObject();
|
||||||
s.rval().setString(cobj->getExtensions());
|
s.rval().setString(cobj->getExtensions());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user