![]() |
C-chat
|
Server file. More...
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include "server.h"
#include "../common/packets.h"
#include "communication.h"
#include "handshake.h"
#include "client-info.h"
#include "file-transfer.h"
#include "room.h"
Functions | |
void | handleServerClose (int signal) |
Catch interrupt signal. More... | |
void | handleClientsPackets (Client *client) |
Relay messages sent by given client to all known clients. More... | |
THREAD_ENTRY_POINT | clientThread (void *idPnt) |
int | main () |
Program entry point. | |
Variables | |
ReadWriteLock | clientsLock |
ReadWriteLock | roomsLock |
Client * | clients [NUMBER_CLIENT_MAX] = {NULL} |
Room * | rooms [NUMBER_ROOM_MAX] = {NULL} |
Server file.
Allows multiple clients to discuss, relaying messages between them.
void handleClientsPackets | ( | Client * | client | ) |
Relay messages sent by given client to all known clients.
Waits for an incoming message, and broadcast it (in a correctly formed relayed message) to all known clients.
client | The client to wait messages from |
void handleServerClose | ( | int | signal | ) |
Catch interrupt signal.
signal | Incoming signal |
Room* rooms[NUMBER_ROOM_MAX] = {NULL} |
An array containing all pointers to existing rooms.
It can be written by any client thread at any time if a client creates or deletes a room. It can be read by any client thread at any time if a client joins a room.
We MUST acquire roomsLock to access this field.