i want a squid to suplex me
This commit is contained in:
parent
baa781df4f
commit
8152424c7a
7 changed files with 55 additions and 2 deletions
|
@ -7,4 +7,6 @@
|
|||
|
||||
#define KEY_LF 10
|
||||
|
||||
#define MAX_CONNS 100
|
||||
|
||||
#endif
|
||||
|
|
0
src/packet.c
Normal file
0
src/packet.c
Normal file
0
src/packet.h
Normal file
0
src/packet.h
Normal file
|
@ -7,6 +7,8 @@ void server() {
|
|||
sock_start(sock);
|
||||
sock_set_nonblocking(sock);
|
||||
|
||||
|
||||
|
||||
flimit_t vsync;
|
||||
for(;;) {
|
||||
frame_limit_tick(&vsync);
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
#include "queue.h"
|
||||
#include "flimit.h"
|
||||
|
||||
#define MAX_CONNS 100
|
||||
|
||||
void server();
|
||||
|
||||
#endif
|
||||
|
|
26
src/server/user.c
Normal file
26
src/server/user.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include "user.h"
|
||||
|
||||
struct {
|
||||
list_t *active_users;
|
||||
user_t **users;
|
||||
} ctx;
|
||||
|
||||
void user_ctx_init() {
|
||||
ctx.active_users = list_init();
|
||||
ctx.users = (user_t**)malloc(MAX_CONNS * sizeof(user_t*));
|
||||
|
||||
int i;
|
||||
for(i = 0; i < MAX_CONNS; ++i)
|
||||
ctx.users[i] = NULL;
|
||||
}
|
||||
|
||||
void user_ctx_free() {
|
||||
list_free(ctx.active_users);
|
||||
|
||||
int i;
|
||||
for(i = 0; i < MAX_CONNS; ++i)
|
||||
if(ctx.users[i] != NULL)
|
||||
free(ctx.users[i]);
|
||||
|
||||
free(ctx.users);
|
||||
}
|
25
src/server/user.h
Normal file
25
src/server/user.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef USER_H
|
||||
#define USER_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "common.h"
|
||||
|
||||
typedef struct user_t user_t;
|
||||
struct user_t {
|
||||
queue_t *in_packets;
|
||||
pthread_mutex_t mx_in_packets;
|
||||
|
||||
queue_t *out_packets;
|
||||
pthread_mutex_t mx_out_packets;
|
||||
|
||||
socket_t *sock;
|
||||
uint16_t context_id;
|
||||
uint16_t x, y;
|
||||
};
|
||||
|
||||
void user_ctx_init();
|
||||
|
||||
void user_ctx_free();
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue