Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
7a33d10b
Commit
7a33d10b
authored
Mar 31, 2021
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[uwebsocketgate]: foxed pong message, used short ping message
parent
5f6cefba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
16 deletions
+12
-16
UWebSocketGate.cc
extensions/UWebSocketGate/UWebSocketGate.cc
+12
-11
uniset2.files
uniset2.files
+0
-5
No files found.
extensions/UWebSocketGate/UWebSocketGate.cc
View file @
7a33d10b
...
@@ -497,7 +497,7 @@ Poco::JSON::Object::Ptr UWebSocketGate::respError( Poco::Net::HTTPServerResponse
...
@@ -497,7 +497,7 @@ Poco::JSON::Object::Ptr UWebSocketGate::respError( Poco::Net::HTTPServerResponse
return
jdata
;
return
jdata
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UWebSocketGate
::
onWebSocketSession
(
Poco
::
Net
::
HTTPServerRequest
&
req
,
Poco
::
Net
::
HTTPServerResponse
&
resp
)
void
UWebSocketGate
::
onWebSocketSession
(
Poco
::
Net
::
HTTPServerRequest
&
req
,
Poco
::
Net
::
HTTPServerResponse
&
resp
)
{
{
using
Poco
::
Net
::
WebSocket
;
using
Poco
::
Net
::
WebSocket
;
using
Poco
::
Net
::
WebSocketException
;
using
Poco
::
Net
::
WebSocketException
;
...
@@ -597,7 +597,6 @@ std::shared_ptr<UWebSocketGate::UWebSocket> UWebSocketGate::newWebSocket( Poco::
...
@@ -597,7 +597,6 @@ std::shared_ptr<UWebSocketGate::UWebSocket> UWebSocketGate::newWebSocket( Poco::
auto
idlist
=
uniset
::
explode
(
slist
);
auto
idlist
=
uniset
::
explode
(
slist
);
{
{
uniset_rwmutex_wrlock
lock
(
wsocksMutex
);
ws
=
make_shared
<
UWebSocket
>
(
req
,
resp
);
ws
=
make_shared
<
UWebSocket
>
(
req
,
resp
);
ws
->
setHearbeatTime
(
wsHeartbeatTime_sec
);
ws
->
setHearbeatTime
(
wsHeartbeatTime_sec
);
ws
->
setSendPeriod
(
wsSendTime_sec
);
ws
->
setSendPeriod
(
wsSendTime_sec
);
...
@@ -611,6 +610,7 @@ std::shared_ptr<UWebSocketGate::UWebSocket> UWebSocketGate::newWebSocket( Poco::
...
@@ -611,6 +610,7 @@ std::shared_ptr<UWebSocketGate::UWebSocket> UWebSocketGate::newWebSocket( Poco::
ws
->
ask
(
i
);
ws
->
ask
(
i
);
}
}
uniset_rwmutex_wrlock
lock
(
wsocksMutex
);
wsocks
.
emplace_back
(
ws
);
wsocks
.
emplace_back
(
ws
);
}
}
...
@@ -620,7 +620,7 @@ std::shared_ptr<UWebSocketGate::UWebSocket> UWebSocketGate::newWebSocket( Poco::
...
@@ -620,7 +620,7 @@ std::shared_ptr<UWebSocketGate::UWebSocket> UWebSocketGate::newWebSocket( Poco::
return
ws
;
return
ws
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UWebSocketGate
::
delWebSocket
(
std
::
shared_ptr
<
UWebSocket
>&
ws
)
void
UWebSocketGate
::
delWebSocket
(
std
::
shared_ptr
<
UWebSocket
>&
ws
)
{
{
uniset_rwmutex_wrlock
lock
(
wsocksMutex
);
uniset_rwmutex_wrlock
lock
(
wsocksMutex
);
...
@@ -635,10 +635,9 @@ void UWebSocketGate::delWebSocket(std::shared_ptr<UWebSocket>& ws )
...
@@ -635,10 +635,9 @@ void UWebSocketGate::delWebSocket(std::shared_ptr<UWebSocket>& ws )
}
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
const
std
::
string
UWebSocketGate
::
UWebSocket
::
ping_str
=
"{
\"
data
\"
: [{
\"
type
\"
:
\"
Ping
\"
}]}"
;
UWebSocketGate
::
UWebSocket
::
UWebSocket
(
Poco
::
Net
::
HTTPServerRequest
*
_req
,
UWebSocketGate
::
UWebSocket
::
UWebSocket
(
Poco
::
Net
::
HTTPServerRequest
*
_req
,
Poco
::
Net
::
HTTPServerResponse
*
_resp
)
:
Poco
::
Net
::
HTTPServerResponse
*
_resp
)
:
Poco
::
Net
::
WebSocket
(
*
_req
,
*
_resp
),
Poco
::
Net
::
WebSocket
(
*
_req
,
*
_resp
),
req
(
_req
),
req
(
_req
),
resp
(
_resp
)
resp
(
_resp
)
...
@@ -694,7 +693,7 @@ bool UWebSocketGate::UWebSocket::isActive()
...
@@ -694,7 +693,7 @@ bool UWebSocketGate::UWebSocket::isActive()
return
iosend
.
is_active
();
return
iosend
.
is_active
();
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UWebSocketGate
::
UWebSocket
::
set
(
ev
::
dynamic_loop
&
loop
,
std
::
shared_ptr
<
ev
::
async
>
a
)
void
UWebSocketGate
::
UWebSocket
::
set
(
ev
::
dynamic_loop
&
loop
,
std
::
shared_ptr
<
ev
::
async
>
a
)
{
{
iosend
.
set
(
loop
);
iosend
.
set
(
loop
);
ioping
.
set
(
loop
);
ioping
.
set
(
loop
);
...
@@ -749,6 +748,8 @@ void UWebSocketGate::UWebSocket::send( ev::timer& t, int revents )
...
@@ -749,6 +748,8 @@ void UWebSocketGate::UWebSocket::send( ev::timer& t, int revents )
}
}
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
const
std
::
string
UWebSocketGate
::
UWebSocket
::
ping_str
=
"."
;
// "{\"data\": [{\"type\": \"Ping\"}]}";
void
UWebSocketGate
::
UWebSocket
::
ping
(
ev
::
timer
&
t
,
int
revents
)
void
UWebSocketGate
::
UWebSocket
::
ping
(
ev
::
timer
&
t
,
int
revents
)
{
{
if
(
EV_ERROR
&
revents
)
if
(
EV_ERROR
&
revents
)
...
@@ -799,11 +800,11 @@ void UWebSocketGate::UWebSocket::read( ev::io& io, int revents )
...
@@ -799,11 +800,11 @@ void UWebSocketGate::UWebSocket::read( ev::io& io, int revents )
if
(
(
flags
&
WebSocket
::
FRAME_OP_BITMASK
)
==
WebSocket
::
FRAME_OP_PING
)
if
(
(
flags
&
WebSocket
::
FRAME_OP_BITMASK
)
==
WebSocket
::
FRAME_OP_PING
)
{
{
sendFrame
(
rbuf
,
n
,
WebSocket
::
FRAME_OP_PONG
);
sendFrame
(
rbuf
,
n
,
WebSocket
::
FRAME_
FLAG_FIN
|
WebSocket
::
FRAME_
OP_PONG
);
return
;
return
;
}
}
if
(
(
flags
&
WebSocket
::
FRAME_OP_BITMASK
)
==
WebSocket
::
FRAME_OP_PONG
)
if
(
(
flags
&
WebSocket
::
FRAME_OP_BITMASK
)
&
WebSocket
::
FRAME_OP_PONG
)
return
;
return
;
...
@@ -926,7 +927,7 @@ void UWebSocketGate::UWebSocket::sensorInfo( const uniset::SensorMessage* sm )
...
@@ -926,7 +927,7 @@ void UWebSocketGate::UWebSocket::sensorInfo( const uniset::SensorMessage* sm )
ioping
.
stop
();
ioping
.
stop
();
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UWebSocketGate
::
UWebSocket
::
doCommand
(
const
std
::
shared_ptr
<
SMInterface
>&
ui
)
void
UWebSocketGate
::
UWebSocket
::
doCommand
(
const
std
::
shared_ptr
<
SMInterface
>&
ui
)
{
{
if
(
qcmd
.
empty
()
)
if
(
qcmd
.
empty
()
)
return
;
return
;
...
@@ -1171,7 +1172,7 @@ void UWebSocketGate::UWebSocket::write()
...
@@ -1171,7 +1172,7 @@ void UWebSocketGate::UWebSocket::write()
}
}
catch
(
WebSocketException
&
exc
)
catch
(
WebSocketException
&
exc
)
{
{
cerr
<<
"(sendFrame): ERROR: "
<<
exc
.
displayText
()
<<
endl
;
mylog3
<<
"(sendFrame): ERROR: "
<<
exc
.
displayText
()
<<
endl
;
switch
(
exc
.
code
()
)
switch
(
exc
.
code
()
)
{
{
...
...
uniset2.files
View file @
7a33d10b
...
@@ -297,11 +297,6 @@
...
@@ -297,11 +297,6 @@
./extensions/UniNetwork/uninet.cc
./extensions/UniNetwork/uninet.cc
./extensions/UWebSocketGate/main.cc
./extensions/UWebSocketGate/main.cc
./extensions/UWebSocketGate/Makefile.am
./extensions/UWebSocketGate/Makefile.am
./extensions/UWebSocketGate.old/main.cc
./extensions/UWebSocketGate.old/Makefile.am
./extensions/UWebSocketGate.old/UWebSocketGate.cc
./extensions/UWebSocketGate.old/UWebSocketGate.h
./extensions/UWebSocketGate.old/UWebSocketGateSugar.h
./extensions/UWebSocketGate/tests/Makefile.am
./extensions/UWebSocketGate/tests/Makefile.am
./extensions/UWebSocketGate/tests/tests_with_sm.cc
./extensions/UWebSocketGate/tests/tests_with_sm.cc
./extensions/UWebSocketGate/tests/test_uwebsocketgate.cc
./extensions/UWebSocketGate/tests/test_uwebsocketgate.cc
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment