aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-03-13 02:37:33 -0400
committerB. Watson <urchlay@slackware.uk>2026-03-13 02:37:33 -0400
commitfc503a1093f3d971e1bc2082122031a0761bd9ed (patch)
tree1de455d23a446236f2f50ac1f5090a3c046b1315 /src/main.c
parent8b76e79585aa1ed0a3bc4c1708f2d270aac239fc (diff)
downloadfujinet-chat-fc503a1093f3d971e1bc2082122031a0761bd9ed.tar.gz
On disconnect or connect fail, sleep between retries, incremental backoff timer.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index 59f751e..b62b456 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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();
}
}