From e528950ac7a2d23512be2a06378525b00be74185 Mon Sep 17 00:00:00 2001 From: oroborus Date: Thu, 26 Jun 2008 19:57:20 +0000 Subject: - oprava chyby, server s GUI bol niekedy pozadu, lebo spracoval iba jeden packet aj ked ich bolo viac - jednodny subsystem na odosielanie packetov zo servera clientom ( checkFront.c sa pouziva aj na odosielaie sprav, ktorych prichod sa nemusi kontrolovat ) git-svn-id: http://opensvn.csie.org/tuxanci_ng@74 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/checkFront.c | 55 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 20 deletions(-) (limited to 'src/checkFront.c') diff --git a/src/checkFront.c b/src/checkFront.c index 340a8d8..7baa4f2 100644 --- a/src/checkFront.c +++ b/src/checkFront.c @@ -17,9 +17,10 @@ typedef struct struct_checkfront_t my_time_t time; int id; int count; + int type; } checkfront_t; -static checkfront_t* newCheck(char *s, int id) +static checkfront_t* newCheck(char *s, int type, int id) { checkfront_t *new; @@ -31,6 +32,7 @@ static checkfront_t* newCheck(char *s, int id) new->msg = strdup(s); new->time = getMyTime(); new->id = id; + new->type = type; new->count = 0; return new; @@ -44,18 +46,16 @@ static void destroyCheck(checkfront_t *p) free(p); } - list_t* newCheckFront() { return newList(); } -void addMsgInCheckFront(list_t *list, char *msg, int id) +void addMsgInCheckFront(list_t *list, char *msg, int type, int id) { - addList(list, newCheck(msg, id) ); + addList(list, newCheck(msg, type, id) ); } - void eventMsgInCheckFront(client_t *client) { my_time_t currentTime; @@ -69,22 +69,37 @@ void eventMsgInCheckFront(client_t *client) this = (checkfront_t *)client->listCheck->list[i]; - if( this->count == 0 || currentTime - this->time > CHECK_FRONT_SEND_TIME_INTERVAL ) - { - sendClient(client, this->msg); - this->time = currentTime; - this->count++; - } - - if( this->count > CHECK_FRONT_MAX_COUNT_SEND ) + switch( this->type ) { - if( isRegisterID(this->id) != -1 ) - { - delID(this->id); - } - - delListItem(client->listCheck, i, destroyCheck); - i--; + case CHECK_FORNT_TYPE_SIMPLE : + sendClient(client, this->msg); + delListItem(client->listCheck, i, destroyCheck); + i--; + break; + + case CHECK_FORNT_TYPE_CHECK : + if( this->count == 0 || currentTime - this->time > CHECK_FRONT_SEND_TIME_INTERVAL ) + { + sendClient(client, this->msg); + this->time = currentTime; + this->count++; + } + + if( this->count > CHECK_FRONT_MAX_COUNT_SEND ) + { + if( isRegisterID(this->id) != -1 ) + { + delID(this->id); + } + + delListItem(client->listCheck, i, destroyCheck); + i--; + } + break; + + default : + assert( ! "Zly typ !" ); + break; } } } -- cgit v1.2.3