Skip to content

Commit

Permalink
Delay kcp init
Browse files Browse the repository at this point in the history
  • Loading branch information
Chion82 committed Jan 31, 2017
1 parent 9d9420d commit ba98423
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
10 changes: 8 additions & 2 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ void accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents) {

}

void re_init_kcp_cb(struct ev_loop *loop, struct ev_timer* timer, int revents) {
send_packet(&packetinfo, INIT_KCP, 8, 0);
}

int main(int argc, char* argv[]) {

signal(SIGPIPE, SIG_IGN);
Expand Down Expand Up @@ -155,14 +159,16 @@ int main(int argc, char* argv[]) {
}
}

last_recv_heart_beat = getclock();

init_packet(&packetinfo);
set_packet_recv_nonblocking();

loop = ev_default_loop(0);

struct ev_io w_accept;
struct ev_timer init_kcp_timer;

ev_timer_init(&init_kcp_timer, re_init_kcp_cb, 1, 0);
ev_timer_start(loop, &init_kcp_timer);

ev_timer_init(&kcp_update_timer, kcp_update_timer_cb, 0.1, 0.003);
ev_timer_start(loop, &kcp_update_timer);
Expand Down
5 changes: 0 additions & 5 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,6 @@ void init_kcp() {
ikcp_setmtu(kcp, KCP_MTU);
ikcp_wndsize(kcp, KCP_MAX_WND_SIZE, KCP_MAX_WND_SIZE);
ikcp_nodelay(kcp, kcpconfig.nodelay, kcpconfig.interval, kcpconfig.resend, kcpconfig.nc);

#ifndef SERVER
send_packet(&packetinfo, "", 1, 0);
send_packet(&packetinfo, INIT_KCP, 8, 0);
#endif
}

int iqueue_get_len(struct IQUEUEHEAD* queue) {
Expand Down
2 changes: 0 additions & 2 deletions server.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ int main(int argc, char* argv[]) {
}
}

last_recv_heart_beat = getclock();

loop = ev_default_loop(0);

init_packet(&packetinfo);
Expand Down

0 comments on commit ba98423

Please sign in to comment.