summaryrefslogtreecommitdiff
path: root/jet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'jet.cpp')
-rw-r--r--jet.cpp26
1 files changed, 2 insertions, 24 deletions
diff --git a/jet.cpp b/jet.cpp
index 1ae3eeb..2006a77 100644
--- a/jet.cpp
+++ b/jet.cpp
@@ -1,6 +1,6 @@
#include <stdio.h>
-#include <string.h>
#include <stdint.h>
+#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -19,7 +19,6 @@
#include "client.cpp"
#define PORT 6969
-#define MAX_COMMAND_SIZE 128
#define MAX_EVENTS 10
int create_listener() {
@@ -32,24 +31,6 @@ int create_listener() {
return s;
}
-void parse_command(char *command, Client *client) {
- char *token = strtok(command, " \n");
- while (token) {
- if (strcmp(token, "show") == 0) {
- client->show();
- } else if (strcmp(token, "move") == 0) {
- client->move();
- } else if (strcmp(token, "push") == 0) {
- client->push();
- } else if (strcmp(token, "pop") == 0) {
- client->pop();
- } else {
- client->args.push(atoi(token));
- }
- token = strtok(0, " \n");
- }
-}
-
int main() {
Buffer scratch("scratch");
scratch.read_file("LICENSE");
@@ -82,10 +63,7 @@ int main() {
clients[clientfd] = c;
epoll_ctl(epollfd, EPOLL_CTL_ADD, clientfd, &ev);
} else {
- char command[MAX_COMMAND_SIZE] = {};
- int clientfd = events[i].data.fd;
- read(clientfd, command, MAX_COMMAND_SIZE - 1);
- parse_command(command, clients[clientfd]);
+ clients[events[i].data.fd]->parse_message();
}
}
}