Small client-server app demonstrates how to organize live chat without persistent connection. The benefits are
- Number of server connections are NOT increases
- Simple logic without connect/recconnection code
- Server may be tested more easily
- Client sends getUpdates request, server sends reply if updates for this client found, otherwise it waits up to 60 sec. If updates appeared server returns it immediately
- After getUpdate response client send request again. If client stops to send these requests, server assumes that client disconnected and removes user from chat. So, server has only one active connection with client
Install go 1.19+. Just download go installer for your platform here and install. Then open command prompt or bash and check go tools availability
$ go version
Clone the project, open command prompt or bash in root folder and run
$ go build
$ ./easychat server
$ ./easychat client