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 )
if( !(revents & EV_READ) )
return;
if( cancelled )
return;
using Poco::Net::WebSocket;
using Poco::Net::WebSocketException;
using Poco::Net::HTTPResponse;
......@@ -749,6 +752,10 @@ void UWebSocketGate::UWebSocket::read( ev::io& io, int revents )
return;
}
if( (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_PONG)
return;
if( (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE )
{
term();
......@@ -978,21 +985,14 @@ void UWebSocketGate::UWebSocket::onCommand( const string& cmdtxt )
mylog3 << "(websocket): " << req->clientAddress().toString()
<< " error: bad command format '" << cmdtxt << "'. Len must be > 4" << endl;
using Poco::Net::WebSocket;
using Poco::Net::WebSocketException;
using Poco::Net::HTTPResponse;
using Poco::Net::HTTPServerRequest;
resp->setStatusAndReason(HTTPResponse::HTTP_BAD_REQUEST);
resp->setContentLength(0);
resp->send();
sendError("Unknown command. Command must be > 4 bytes");
return;
}
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;
if( cmd == "set" )
......
......@@ -325,7 +325,7 @@ namespace uniset
double send_sec = { 0.5 };
size_t maxsend = { 5000 };
size_t maxcmd = { 200 };
static int Kbuf = { 10 }; // коэффициент для буфера сообщений (maxsend умножается на Kbuf)
const int Kbuf = { 10 }; // коэффициент для буфера сообщений (maxsend умножается на Kbuf)
ev::timer ioping;
double ping_sec = { 3.0 };
......
......@@ -2,4 +2,4 @@
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