Add Dispatcher
This commit is contained in:
parent
6c181cdbc4
commit
890d327b5b
1 changed files with 24 additions and 0 deletions
24
src/server.c
24
src/server.c
|
@ -220,7 +220,31 @@ int disconnect_client(int client_id) {
|
|||
}
|
||||
|
||||
/* Thread, parses and handles messages */
|
||||
/* Thread, Dispatcher : pop message from the stack, parse it and send it to the good ClientSender */
|
||||
void *Dispatcher(void *arg) {
|
||||
char buf = 0;
|
||||
char *message[];
|
||||
int n = 0 ;
|
||||
int k = 0 ;
|
||||
|
||||
while (1) {
|
||||
/* Read 1 bytes at a time, because we don't know how long the message will be */
|
||||
while ((n = read(stack_fd, buf, 1)) > 0) {
|
||||
message[k++] = buf;
|
||||
if (buf == '\n'){
|
||||
k = 0;
|
||||
printf("Message received : %c", &message);
|
||||
|
||||
/* TODO : parse(*message); Do we do that into a separate thread ? */
|
||||
|
||||
/* TODO :Writing Message into pipe */
|
||||
}
|
||||
if (n < 0) {
|
||||
fprintf(stderr, "ERROR: Dispatcher failed to read from stack\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_exit(0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue