protoverse

A metaverse protocol
git clone git://jb55.com/protoverse
Log | Files | Refs | README | LICENSE

commit 9c105a9d400be45a8c1229fc1643ad86d9560b5f
parent 298fa883707d639856eee7ca83c6bfb5dd9dab8b
Author: William Casarin <jb55@jb55.com>
Date:   Thu,  6 Aug 2020 21:28:36 -0700

netcode cleanups

Diffstat:
MMakefile | 2+-
Mclient.c | 18++++++++----------
Mnet.c | 3++-
Mprotoverse.c | 1-
4 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile @@ -18,7 +18,7 @@ test: test.c $(OBJS) $(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@ check: test - ./test + @./test TAGS: fake etags *.c *.h > $@ diff --git a/client.c b/client.c @@ -23,8 +23,6 @@ int protoverse_connect(const char *server_ip_str, int port) struct sockaddr_in server_addr; struct cursor cursor; struct packet packet; - ssize_t sent; - const char msg[] = "hello, world"; make_cursor(buf, buf + sizeof(buf), &cursor); @@ -42,18 +40,18 @@ int protoverse_connect(const char *server_ip_str, int port) server_addr.sin_port = port == 0 || port == -1 ? 1988 : port; server_addr.sin_addr = server_in_addr; - printf("sending '%s' to %s\n", msg, server_ip_str); - packet.type = PKT_CHAT; packet.data.chat.message = "hello, world"; - packet.data.chat.sender = 1; + packet.data.chat.sender = 0xFFFFFF; - sent = send_packet(sockfd, (struct sockaddr*)&server_addr, - sizeof(server_addr), &packet); + send_packet(sockfd, (struct sockaddr*)&server_addr, + sizeof(server_addr), &packet); - if (!sent) { - exit(1); - } + packet.type = PKT_FETCH_DATA; + packet.data.fetch.path = "/some/room.space"; + + send_packet(sockfd, (struct sockaddr*)&server_addr, + sizeof(server_addr), &packet); return 1; } diff --git a/net.c b/net.c @@ -228,7 +228,8 @@ void print_packet(struct packet *packet) packet->data.chat.message); return; case PKT_FETCH_DATA: - printf("(fetch)\n"); + printf("(fetch (path \"%s\"))\n", + packet->data.fetch.path); return; case PKT_NUM_TYPES: break; diff --git a/protoverse.c b/protoverse.c @@ -82,7 +82,6 @@ static int parse_file(struct parser *parser, const char *filename, u16 *root) return 0; } - ok = tokenize_cells(file_buf, count, &tokens); if (!ok) {