Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
jlib
Commits
f9576591
Commit
f9576591
authored
Sep 03, 2020
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
0754f4e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
simple_libevent_client.cpp
jlib/net/simple_libevent_client.cpp
+11
-4
test.sln
test/test.sln
+5
-0
No files found.
jlib/net/simple_libevent_client.cpp
View file @
f9576591
...
...
@@ -159,12 +159,12 @@ struct simple_libevent_client::Impl
static
void
timercb
(
evutil_socket_t
,
short
,
void
*
user_data
)
{
simple_libevent_client
*
client
=
(
simple_libevent_client
*
)
user_data
;
struct
timeval
tv
=
{
1
,
0
};
if
(
client
->
strictTimer_
)
{
if
(
client
->
userData_
&&
client
->
onTimer_
)
{
client
->
onTimer_
(
client
->
userData_
);
}
struct
timeval
tv
=
{
client
->
timeout_
,
0
};
event_add
(
event_new
(
client
->
impl_
->
base
,
-
1
,
0
,
Impl
::
timercb
,
client
),
&
tv
);
tv
.
tv_sec
=
client
->
timeout_
;
}
else
{
auto
now
=
std
::
chrono
::
steady_clock
::
now
();
auto
diff
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
now
-
client
->
lastTimeSendData
);
...
...
@@ -172,15 +172,20 @@ struct simple_libevent_client::Impl
if
(
client
->
userData_
&&
client
->
onTimer_
)
{
client
->
onTimer_
(
client
->
userData_
);
}
}
else
{
return
;
}
struct
timeval
tv
=
{
1
,
0
};
}
if
(
client
->
connected_
)
{
client
->
impl_
->
timer
=
event_new
(
client
->
impl_
->
base
,
-
1
,
0
,
Impl
::
timercb
,
client
);
event_add
(
client
->
impl_
->
timer
,
&
tv
);
}
}
}
static
void
reconn_timercb
(
evutil_socket_t
,
short
,
void
*
user_data
)
{
AUTO_LOG_FUNCTION
;
simple_libevent_client
*
client
=
(
simple_libevent_client
*
)
user_data
;
do
{
...
...
@@ -220,6 +225,7 @@ struct simple_libevent_client::Impl
bool
simple_libevent_client
::
start
(
const
std
::
string
&
ip
,
uint16_t
port
,
std
::
string
&
msg
)
{
AUTO_LOG_FUNCTION
;
do
{
stop
();
...
...
@@ -271,6 +277,7 @@ bool simple_libevent_client::start(const std::string& ip, uint16_t port, std::st
void
simple_libevent_client
::
stop
()
{
AUTO_LOG_FUNCTION
;
std
::
lock_guard
<
std
::
mutex
>
lg
(
mutex_
);
if
(
!
impl_
)
{
return
;
}
...
...
test/test.sln
View file @
f9576591
...
...
@@ -87,6 +87,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net", "net", "{FEAECF59-4F3
..\jlib\net\icmp_header.hpp = ..\jlib\net\icmp_header.hpp
..\jlib\net\ipv4_header.hpp = ..\jlib\net\ipv4_header.hpp
..\jlib\net\ping.h = ..\jlib\net\ping.h
..\jlib\net\resolve_fastest_ip.h = ..\jlib\net\resolve_fastest_ip.h
..\jlib\net\simple_libevent_client.cpp = ..\jlib\net\simple_libevent_client.cpp
..\jlib\net\simple_libevent_client.h = ..\jlib\net\simple_libevent_client.h
..\jlib\net\simple_libevent_server.cpp = ..\jlib\net\simple_libevent_server.cpp
..\jlib\net\simple_libevent_server.h = ..\jlib\net\simple_libevent_server.h
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "util", "util", "{E13021FA-C9A3-4627-B7EF-16E97B7E2E14}"
...
...
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