diff options
| author | B. Watson <urchlay@slackware.uk> | 2026-03-13 02:37:33 -0400 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2026-03-13 02:37:33 -0400 |
| commit | fc503a1093f3d971e1bc2082122031a0761bd9ed (patch) | |
| tree | 1de455d23a446236f2f50ac1f5090a3c046b1315 /src | |
| parent | 8b76e79585aa1ed0a3bc4c1708f2d270aac239fc (diff) | |
| download | fujinet-chat-fc503a1093f3d971e1bc2082122031a0761bd9ed.tar.gz | |
On disconnect or connect fail, sleep between retries, incremental backoff timer.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd.c | 1 | ||||
| -rw-r--r-- | src/irc.c | 4 | ||||
| -rw-r--r-- | src/irc.h | 1 | ||||
| -rw-r--r-- | src/main.c | 31 |
4 files changed, 29 insertions, 8 deletions
@@ -174,6 +174,7 @@ static void do_j(void) { } static void do_quit(void) { + reconnect_timeout = 0; /* do not reconnect on /quit */ txbuf_set_str("QUIT"); if(arg1) txbuf_append_str2(" :", arg1); @@ -628,15 +628,15 @@ int irc_read(void) { err = nstatus(conf->url); if(err != 1) { + scr_display(SCR_SERVER); regged = 0; if(err == 136) { scr_print_current("Disconnected"); } else { print_errnum(); } - scr_print_current(", press any key...\n"); + scr_eol_current(); bell(); - cgetc(); return 0; } @@ -10,6 +10,7 @@ extern unsigned short rxbuflen; extern unsigned char err; extern unsigned char trip; extern char hz; +extern char reconnect_timeout; extern unsigned int txbuflen; extern char *tx_buf; @@ -23,7 +23,7 @@ void *old_vprced; // old PROCEED vector, restored on exit. unsigned short rxbuflen; // RX buffer length unsigned int txbuflen; // TX buffer length char hz; /* 50 for PAL, 60 for NSTC */ -char reconnect_timeout; +char reconnect_timeout = 1; /* TODO: user modes (default +iw), fg/bg color... */ @@ -92,11 +92,10 @@ int fn_connect(void) { err = nopen(conf->url, FNET_TRANSLATION); if(err != SUCCESS) { - bell(); scr_print_current("Connection failed: "); print_errnum(); scr_eol_current(); - cgetc(); + bell(); return 0; } @@ -131,6 +130,27 @@ void init_channels(void) { } void reconnect_wait(void) { + scr_display(SCR_SERVER); + scr_print_current("Press a key"); + + /* IMO, 0xff is easier to understand than KEY_NONE, here */ + OS.cdtmf3 = OS.ch = 0xff; + + if(reconnect_timeout) { + OS.cdtmv3 = reconnect_timeout * hz; + scr_print_current(" or wait "); + itoa(reconnect_timeout, numbuf, 10); + scr_print_current(numbuf); + scr_print_current(" sec"); + if(reconnect_timeout < 64) + reconnect_timeout <<= 1; + } + scr_print_current(" to reconnect.\n"); + + while(OS.cdtmf3 == 0xff && OS.ch == 0xff) + /* NOP */; + + OS.ch = 0xff; } void main(void) { @@ -152,9 +172,8 @@ void main(void) { if(fn_connect()) { irc_register(); irc_loop(); - fn_disconnect(); - } else { - reconnect_wait(); } + fn_disconnect(); + reconnect_wait(); } } |
