Merge pull request #108 from an-tao/dev
Fix a websocket bug in Linux and add ws_test.html for testing
This commit is contained in:
commit
524ad6ce22
|
@ -0,0 +1,23 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<pre id="log"></pre>
|
||||||
|
<script>
|
||||||
|
// helper function: log message to screen
|
||||||
|
function log(msg) {
|
||||||
|
document.getElementById('log').textContent += msg + '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup websocket with callbacks
|
||||||
|
var ws = new WebSocket("ws://127.0.0.1:8848/chat");
|
||||||
|
ws.onopen = function() {
|
||||||
|
log('CONNECT');
|
||||||
|
ws.send("hello!!!");
|
||||||
|
};
|
||||||
|
ws.onclose = function() {
|
||||||
|
log('DISCONNECT');
|
||||||
|
};
|
||||||
|
ws.onmessage = function(event) {
|
||||||
|
log('MESSAGE: ' + event.data);
|
||||||
|
ws.send(event.data);
|
||||||
|
ws.send(event.data);
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -318,6 +318,9 @@ void HttpAppFrameworkImpl::run()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
serverPtr->setHttpAsyncCallback(std::bind(&HttpAppFrameworkImpl::onAsyncRequest, this, _1, _2));
|
serverPtr->setHttpAsyncCallback(std::bind(&HttpAppFrameworkImpl::onAsyncRequest, this, _1, _2));
|
||||||
|
serverPtr->setNewWebsocketCallback(std::bind(&HttpAppFrameworkImpl::onNewWebsockRequest, this, _1, _2, _3));
|
||||||
|
serverPtr->setWebsocketMessageCallback(std::bind(&HttpAppFrameworkImpl::onWebsockMessage, this, _1, _2));
|
||||||
|
serverPtr->setDisconnectWebsocketCallback(std::bind(&HttpAppFrameworkImpl::onWebsockDisconnect, this, _1));
|
||||||
serverPtr->setConnectionCallback(std::bind(&HttpAppFrameworkImpl::onConnection, this, _1));
|
serverPtr->setConnectionCallback(std::bind(&HttpAppFrameworkImpl::onConnection, this, _1));
|
||||||
serverPtr->kickoffIdleConnections(_idleConnectionTimeout);
|
serverPtr->kickoffIdleConnections(_idleConnectionTimeout);
|
||||||
serverPtr->start();
|
serverPtr->start();
|
||||||
|
|
Loading…
Reference in New Issue