mirror of https://github.com/axmolengine/axmol.git
issue #2823: firefox remote connection ok.
This commit is contained in:
parent
2e07b0736b
commit
c381e4ce50
|
@ -1938,7 +1938,8 @@ void ScriptingCore::enableDebugger() {
|
|||
JS_DefineFunction(cx_, debugGlobal_, "_unlockVM", JSBDebug_UnlockExecution, 0, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
runScript("jsb_debugger.js", debugGlobal_);
|
||||
|
||||
runScript("SysTest/script.js", debugGlobal_);
|
||||
|
||||
// prepare the debugger
|
||||
jsval argv = OBJECT_TO_JSVAL(global_);
|
||||
jsval outval;
|
||||
|
@ -2166,6 +2167,13 @@ static void clearBuffers() {
|
|||
}
|
||||
}
|
||||
|
||||
static int replyToClient(int socket, const std::string& buf)
|
||||
{
|
||||
std::stringstream bufSend;
|
||||
bufSend << buf.length() << ":" << buf;
|
||||
return ::send(socket, bufSend.str().c_str(), bufSend.str().length(), 0);
|
||||
}
|
||||
|
||||
static void serverEntryPoint(void)
|
||||
{
|
||||
// start a server, accept the connection and keep reading data from it
|
||||
|
@ -2218,25 +2226,172 @@ static void serverEntryPoint(void)
|
|||
|
||||
listen(s, 1);
|
||||
|
||||
int recieveIndex = 0;
|
||||
while (true) {
|
||||
clientSocket = accept(s, NULL, NULL);
|
||||
|
||||
if (clientSocket < 0)
|
||||
{
|
||||
TRACE_DEBUGGER_SERVER("debug server : error on accept");
|
||||
return;
|
||||
} else {
|
||||
{
|
||||
TRACE_DEBUGGER_SERVER("debug server : error on accept");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// read/write data
|
||||
TRACE_DEBUGGER_SERVER("debug server : client connected");
|
||||
char buf[256];
|
||||
int readBytes;
|
||||
while ((readBytes = read(clientSocket, buf, 256)) > 0) {
|
||||
|
||||
if (recieveIndex == 0)
|
||||
{
|
||||
replyToClient(clientSocket, "{\"from\":\"root\",\"applicationType\":\"browser\",\"traits\":{\"sources\": true}}");
|
||||
++recieveIndex;
|
||||
}
|
||||
|
||||
|
||||
char buf[256] = {0};
|
||||
int readBytes = 0;
|
||||
while ((readBytes = ::recv(clientSocket, buf, sizeof(buf), 0)) > 0)
|
||||
{
|
||||
buf[readBytes] = '\0';
|
||||
TRACE_DEBUGGER_SERVER("debug server : received command >%s", buf);
|
||||
|
||||
if (recieveIndex == 1)
|
||||
{
|
||||
replyToClient(clientSocket, "{ \"from\":\"root\", \"tabs\":[{ \"actor\":\"JSBTabActor\", \"title\":\"Hello cocos2d-x JSB\", \"url\":\"http://www.cocos2d-x.org\" }], \"selected\":0 }");
|
||||
}
|
||||
else if (recieveIndex == 2)
|
||||
{
|
||||
replyToClient(clientSocket, "{ \"from\":\"JSBTabActor\", \"type\":\"tabAttached\", \"threadActor\":\"tabThreadActor111\" }");
|
||||
}
|
||||
else if (recieveIndex == 3)
|
||||
{
|
||||
replyToClient(clientSocket, "{\
|
||||
\"from\": \"tabThreadActor111\",\
|
||||
\"type\": \"paused\",\
|
||||
\"actor\": \"JSBTabActor\",\
|
||||
\"poppedFrames\": [],\
|
||||
\"why\": {\
|
||||
\"type\": \"attached\"\
|
||||
}\
|
||||
}");
|
||||
|
||||
|
||||
|
||||
//replyToClient(clientSocket, "{ \"from\":\"JSBTabActor\", \"type\":\"tabNavigated\", \"state\":\"start\", \"url\":\"my_url.js\" }");
|
||||
}
|
||||
else if (recieveIndex == 4)
|
||||
{
|
||||
// replyToClient(clientSocket, "{\"from\": \"tabThreadActor111\",\
|
||||
// \"type\": \"newSource\",\
|
||||
// \"source\": {\
|
||||
// \"actor\": \"source_actor2\",\
|
||||
// \"url\": \"http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\",\
|
||||
// \"isBlackBoxed\": false\
|
||||
// }}");
|
||||
|
||||
replyToClient(clientSocket, "{\
|
||||
\"from\": \"tabThreadActor111\",\
|
||||
\"type\": \"newSource\",\
|
||||
\"source\": {\
|
||||
\"actor\": \"source_actor1\",\
|
||||
\"url\": \"file://~/Project/cocos2d-html5/cocos2d/CCDirector.js\",\
|
||||
\"isBlackBoxed\": false\
|
||||
}\
|
||||
}");
|
||||
|
||||
replyToClient(clientSocket,
|
||||
"{\
|
||||
\"sources\": [\
|
||||
{\
|
||||
\"actor\": \"source_actor1\",\
|
||||
\"url\": \"file://~/Project/cocos2d-html5/cocos2d/CCDirector.js\",\
|
||||
\"isBlackBoxed\": false\
|
||||
}\
|
||||
],\
|
||||
\"from\": \"tabThreadActor111\"\
|
||||
}");
|
||||
}
|
||||
else if (recieveIndex == 5)
|
||||
{
|
||||
replyToClient(clientSocket, "{\
|
||||
\"from\": \"source_actor1\",\
|
||||
\"source\": {\
|
||||
\"type\": \"longString\",\
|
||||
\"initial\": \"var cc = cc || {}; cc.Director = {};\",\
|
||||
\"length\": 100,\
|
||||
\"actor\": \"conn2.longString48\"\
|
||||
}\
|
||||
}");
|
||||
}
|
||||
else if (recieveIndex == 6)
|
||||
{
|
||||
replyToClient(clientSocket, "{\
|
||||
\"from\": \"conn2.longString48\",\
|
||||
\"substring\": \"var cc = cc || {}; cc.Director = {};\
|
||||
\\ncc.Sprite = {};\"\
|
||||
}");
|
||||
|
||||
|
||||
replyToClient(clientSocket, "{\
|
||||
\"from\": \"tabThreadActor111\",\
|
||||
\"type\": \"resumed\"\
|
||||
}");
|
||||
}
|
||||
else if (recieveIndex == 7)
|
||||
{
|
||||
replyToClient(clientSocket, "{\
|
||||
\"from\": \"tabThreadActor111\",\
|
||||
\"type\": \"resumed\"\
|
||||
}");
|
||||
}
|
||||
else if (recieveIndex == 8)
|
||||
{
|
||||
replyToClient(clientSocket, "{ \"from\":\"tabThreadActor111\", \"actor\":\"breakActor\"}");//, \"actualLocation\":2 }");
|
||||
}
|
||||
else if (recieveIndex == 9)
|
||||
{
|
||||
replyToClient(clientSocket, "{ \"from\":\"breakActor\" }");
|
||||
}
|
||||
else if (recieveIndex == 10)
|
||||
{
|
||||
replyToClient(clientSocket, "{\
|
||||
\"from\": \"tabThreadActor111\",\
|
||||
\"type\": \"resumed\"\
|
||||
}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
std::string recvBuf = buf;
|
||||
auto found = recvBuf.find("setBreakpoint");
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
replyToClient(clientSocket, "{ \"from\":\"tabThreadActor111\", \"actor\":\"breakActor\"}");//, \"actualLocation\":2 }");
|
||||
}
|
||||
|
||||
found = recvBuf.find("delete");
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
replyToClient(clientSocket, "{ \"from\":\"breakActor\" }");
|
||||
}
|
||||
|
||||
found = recvBuf.find("interrupt");
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
replyToClient(clientSocket, "{\
|
||||
\"from\": \"tabThreadActor111\",\
|
||||
\"type\": \"resumed\"\
|
||||
}");
|
||||
}
|
||||
|
||||
}
|
||||
++recieveIndex;
|
||||
// no other thread is using this
|
||||
inData.append(buf);
|
||||
// process any input, send any output
|
||||
clearBuffers();
|
||||
// inData.append(buf);
|
||||
// // process any input, send any output
|
||||
// clearBuffers();
|
||||
} // while(read)
|
||||
|
||||
close(clientSocket);
|
||||
}
|
||||
} // while(true)
|
||||
|
|
|
@ -141,7 +141,7 @@
|
|||
Set this to 1 to enable the debugger
|
||||
*/
|
||||
#ifndef JSB_ENABLE_DEBUGGER
|
||||
#define JSB_ENABLE_DEBUGGER 0
|
||||
#define JSB_ENABLE_DEBUGGER 1
|
||||
#endif // JSB_ENABLE_DEBUGGER
|
||||
|
||||
#if JSB_ENABLE_DEBUGGER
|
||||
|
|
Loading…
Reference in New Issue