summaryrefslogtreecommitdiff
path: root/src/server/jet.cpp
blob: e29005a8c4be7387a492c4842ae7fec8842616c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <common/ipc.cpp>
#include <common/file.cpp>
#include <common/socket.cpp>

#include <server/page.cpp>
#include <server/buffer.cpp>
#include <server/point.cpp>
#include <server/client.cpp>

Client *clients[1024] = {};
Buffer scratch("scratch");

void new_connection(int fd) {
	if (clients[fd]) {
		delete clients[fd];
	}
	clients[fd] = new Client(scratch, fd);
}

void existing_connection(int fd) {
	clients[fd]->parse_message();
}

int main() {
	scratch.read_file("test.txt");

	Socket listener;
	listener.listen(new_connection, existing_connection);
}