diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-06-26 19:57:20 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-06-26 19:57:20 +0000 |
| commit | e528950ac7a2d23512be2a06378525b00be74185 (patch) | |
| tree | 27fc486408154bcf540cdc63a293bfaf51355169 /src/checkFront.c | |
| parent | 3501cd8b1173f6c6d8c84f631734344252ebd31d (diff) | |
- 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
Diffstat (limited to 'src/checkFront.c')
| -rw-r--r-- | src/checkFront.c | 55 |
1 files changed, 35 insertions, 20 deletions
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; } } } |