Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jochen Bauer
spn-relayserver
Commits
59a025b0
Commit
59a025b0
authored
Apr 12, 2018
by
Hubert Denkmair
Browse files
add frame complete callback
parent
aa5ca0e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
relayserver/RelayServer.cpp
View file @
59a025b0
...
...
@@ -31,10 +31,10 @@ RelayServer::RelayServer()
}
);
msg
.
Set
MessageReceived
Callback
(
[](
std
::
vector
<
char
>
data
)
msg
.
Set
FrameComplete
Callback
(
[](
uint64_t
frame_id
)
{
//
std::cout << "
received " << data.size() << " by
te
s
." << std::endl;
std
::
cout
<<
"
frame "
<<
frame_id
<<
" comple
te."
<<
std
::
endl
;
}
);
...
...
relayserver/TcpProtocol.cpp
View file @
59a025b0
...
...
@@ -10,9 +10,9 @@ TcpProtocol::TcpProtocol()
_buf
.
resize
(
BUFFER_SIZE
);
}
void
TcpProtocol
::
Set
MessageReceived
Callback
(
TcpProtocol
::
MessageReceived
Callback
callback
)
void
TcpProtocol
::
Set
FrameComplete
Callback
(
TcpProtocol
::
FrameComplete
Callback
callback
)
{
_
messageReceived
Callback
=
callback
;
_
frameComplete
Callback
=
callback
;
}
bool
TcpProtocol
::
Read
(
int
socket
)
...
...
@@ -119,7 +119,7 @@ void TcpProtocol::OnWorldUpdateReceived(const MsgPackProtocol::WorldUpdateMessag
void
TcpProtocol
::
OnTickReceived
(
const
MsgPackProtocol
::
TickMessage
&
msg
)
{
(
void
)
msg
;
_frameCompleteCallback
(
msg
.
frame_id
)
;
}
void
TcpProtocol
::
OnFoodSpawnReceived
(
const
MsgPackProtocol
::
FoodSpawnMessage
&
msg
)
...
...
relayserver/TcpProtocol.h
View file @
59a025b0
...
...
@@ -14,11 +14,11 @@ using SnakeSegmentItem = MsgPackProtocol::SnakeSegmentItem;
class
TcpProtocol
{
public:
typedef
std
::
function
<
void
(
std
::
vector
<
char
>&
)
>
MessageReceived
Callback
;
typedef
std
::
function
<
void
(
uint64_t
frame_id
)
>
FrameComplete
Callback
;
static
constexpr
const
size_t
BUFFER_SIZE
=
1024
*
1024
;
TcpProtocol
();
void
Set
MessageReceivedCallback
(
MessageReceived
Callback
callback
);
void
Set
FrameCompleteCallback
(
FrameComplete
Callback
callback
);
bool
Read
(
int
socket
);
private:
...
...
@@ -34,7 +34,7 @@ class TcpProtocol
size_t
_bufHead
=
0
;
size_t
_bufTail
=
0
;
MessageReceivedCallback
_messageReceived
Callback
;
FrameCompleteCallback
_frameComplete
Callback
;
std
::
unique_ptr
<
FoodMap
>
_food
;
MsgPackProtocol
::
GameInfoMessage
_gameInfo
;
...
...
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