diff --git a/PROTOCOL.md b/PROTOCOL.md index dcbe1cd..a06b3f2 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -86,7 +86,7 @@ formatted responses are more easily parsed by computers. - `pong ` - Sent in response to server `ping` event to prevent the connection from timing out. - Whether the client sends a `pong` command, or any other command, clients -must write some data to the server at least once every ten minutes. +must write some data to the server at least once every 40 seconds. - `disconnect` - Disconnect from the server. @@ -155,4 +155,4 @@ provide clients with the initial match state. - `ping ` - Sent to clients to prevent their connection from timing out. - Whether the client replies with a `pong` command, or any other command, -clients must write some data to the server at least once every ten minutes. \ No newline at end of file +clients must write some data to the server at least once every 40 seconds. \ No newline at end of file diff --git a/cmd/bgammon-server/server.go b/cmd/bgammon-server/server.go index cbda2ad..ed8c006 100644 --- a/cmd/bgammon-server/server.go +++ b/cmd/bgammon-server/server.go @@ -16,7 +16,7 @@ import ( "code.rocket9labs.com/tslocum/bgammon" ) -const clientTimeout = 10 * time.Minute +const clientTimeout = 40 * time.Second var onlyNumbers = regexp.MustCompile(`^[0-9]+$`) @@ -200,7 +200,7 @@ func (s *server) handleConnection(conn net.Conn) { func (s *server) handlePingClient(c *serverClient) { // TODO only ping when there is no recent activity - t := time.NewTicker(time.Minute * 4) + t := time.NewTicker(30 * time.Second) for { <-t.C @@ -210,7 +210,7 @@ func (s *server) handlePingClient(c *serverClient) { } if len(c.name) == 0 { - c.Terminate("User did not send login command within 2 minutes.") + c.Terminate("User did not send login command within 30 seconds.") t.Stop() return }