42 lines
920 B
C
42 lines
920 B
C
//
|
|
// Created by Ajurna on 29/07/2025.
|
|
//
|
|
|
|
#ifndef SERVER03_H
|
|
#define SERVER03_H
|
|
|
|
|
|
#endif //SERVER03_H
|
|
#pragma once
|
|
#include <winsock2.h>
|
|
|
|
typedef struct ClientConnection {
|
|
SOCKET client;
|
|
char *username;
|
|
} client_connection_t;
|
|
|
|
typedef struct Connections {
|
|
size_t size;
|
|
size_t len;
|
|
client_connection_t *clients;
|
|
} connections_t;
|
|
|
|
typedef struct handleArgs {
|
|
int connection;
|
|
SOCKET client;
|
|
connections_t connections;
|
|
} handle_args_t;
|
|
|
|
|
|
|
|
void *handle_connection(void *args);
|
|
|
|
connections_t *connections_create(int size);
|
|
void connections_destroy(connections_t *connections);
|
|
void connections_append(connections_t *connections, SOCKET client, char *username);
|
|
void connections_remove(connections_t *connections, SOCKET client);
|
|
|
|
char *trim(char *str);
|
|
bool username_is_valid(const char *username);
|
|
|
|
void broadcast(const connections_t *connections, const SOCKET *source, const char *message); |