Chat server and client written in Go (simple prototype). The application heavily utilizes goroutines and channels. Go makes the concurrency easy to use and I had a lot of fun during development of this simple app.
- Start the NATS server
$ go get github.com/nats-io/nats-server; nats-server &
The NATS server listens for client connections on TCP Port 4222.
- Build and run client:
Build and run chat-client
:
$ make run-client
Run chat-client
binaries in cmd/
dir:
$ ./cmd/chat-client/chat-client
- Run HTTP Server
$ make run-http-server
The HTTP server listens for client connections on TCP Port 3000.
$ curl -X POST -d '{"msg":"awesomeness"}' -H 'Content-Type: application/json' http://localhost:3000/messages
{"Msg":"awesomeness"}
$ curl localhost:3000/messages
[{"Msg":"a [21:59:24] hi"},{"Msg":"awesomeness"},{"Msg":"a [21:59:49] pp"}]
I have leveraged below repos on this projects
- Username and timestamp are attached to msg body.
- All messages send and receive are on
msg.test
subject.