Commit 4710006b authored by Pavel Vainerman's avatar Pavel Vainerman Committed by Pavel Vainerman

[uwebsocket]: ping/pong processing

parent 400cfbe2
...@@ -726,6 +726,9 @@ void UWebSocketGate::UWebSocket::read( ev::io& io, int revents ) ...@@ -726,6 +726,9 @@ void UWebSocketGate::UWebSocket::read( ev::io& io, int revents )
if( !(revents & EV_READ) ) if( !(revents & EV_READ) )
return; return;
if( cancelled )
return;
using Poco::Net::WebSocket; using Poco::Net::WebSocket;
using Poco::Net::WebSocketException; using Poco::Net::WebSocketException;
using Poco::Net::HTTPResponse; using Poco::Net::HTTPResponse;
...@@ -749,6 +752,10 @@ void UWebSocketGate::UWebSocket::read( ev::io& io, int revents ) ...@@ -749,6 +752,10 @@ void UWebSocketGate::UWebSocket::read( ev::io& io, int revents )
return; return;
} }
if( (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_PONG)
return;
if( (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE ) if( (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE )
{ {
term(); term();
...@@ -978,21 +985,14 @@ void UWebSocketGate::UWebSocket::onCommand( const string& cmdtxt ) ...@@ -978,21 +985,14 @@ void UWebSocketGate::UWebSocket::onCommand( const string& cmdtxt )
mylog3 << "(websocket): " << req->clientAddress().toString() mylog3 << "(websocket): " << req->clientAddress().toString()
<< " error: bad command format '" << cmdtxt << "'. Len must be > 4" << endl; << " error: bad command format '" << cmdtxt << "'. Len must be > 4" << endl;
using Poco::Net::WebSocket; sendError("Unknown command. Command must be > 4 bytes");
using Poco::Net::WebSocketException;
using Poco::Net::HTTPResponse;
using Poco::Net::HTTPServerRequest;
resp->setStatusAndReason(HTTPResponse::HTTP_BAD_REQUEST);
resp->setContentLength(0);
resp->send();
return; return;
} }
const string cmd = cmdtxt.substr(0, 3); const string cmd = cmdtxt.substr(0, 3);
const string params = cmdtxt.substr(4, cmdtxt.size()); const string params = cmdtxt.substr(4);
myinfo << "(websocket): " << req->clientAddress().toString() myinfo << "(websocket)(command): " << req->clientAddress().toString()
<< "(" << cmd << "): " << params << endl; << "(" << cmd << "): " << params << endl;
if( cmd == "set" ) if( cmd == "set" )
......
...@@ -325,7 +325,7 @@ namespace uniset ...@@ -325,7 +325,7 @@ namespace uniset
double send_sec = { 0.5 }; double send_sec = { 0.5 };
size_t maxsend = { 5000 }; size_t maxsend = { 5000 };
size_t maxcmd = { 200 }; size_t maxcmd = { 200 };
static int Kbuf = { 10 }; // коэффициент для буфера сообщений (maxsend умножается на Kbuf) const int Kbuf = { 10 }; // коэффициент для буфера сообщений (maxsend умножается на Kbuf)
ev::timer ioping; ev::timer ioping;
double ping_sec = { 3.0 }; double ping_sec = { 3.0 };
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
ulimit -Sc 1000000 ulimit -Sc 1000000
uniset2-start.sh -f ./uniset2-wsgate --confile test.xml --ws-name UWebSocketGate1 --ws-log-add-levels crit,warn,level1 $* uniset2-start.sh -f ./uniset2-wsgate --confile test.xml --ws-name UWebSocketGate1 --ws-log-add-levels any $*
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment