Shorten timeout when match is complete
This commit is contained in:
parent
3134ae19c8
commit
0bed4617a8
3 changed files with 18 additions and 12 deletions
|
@ -304,9 +304,15 @@ func (c *Client) handleTimeout() {
|
|||
continue
|
||||
}
|
||||
|
||||
if len(Game.Player2.Name) == 0 && time.Since(c.lastActivity) >= 2*time.Minute {
|
||||
c.Out <- []byte("leave")
|
||||
continue
|
||||
if len(Game.Player2.Name) == 0 {
|
||||
timeout := 2 * time.Minute
|
||||
if Game.Winner != 0 {
|
||||
timeout = 20 * time.Second
|
||||
}
|
||||
if time.Since(c.lastActivity) >= timeout {
|
||||
c.Out <- []byte("leave")
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
t := time.Now()
|
||||
|
|
6
go.mod
6
go.mod
|
@ -3,9 +3,9 @@ module code.rocket9labs.com/tslocum/bgammon-tabula-bot
|
|||
go 1.17
|
||||
|
||||
require (
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231223081447-262d006c714c
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20231223084935-b3664645e2f7
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231225075851-a2fb60cf355b
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20231223213411-12f4416eafe1
|
||||
nhooyr.io/websocket v1.8.10
|
||||
)
|
||||
|
||||
require code.rocket9labs.com/tslocum/bei v0.0.0-20231222205835-c070d7c7d5f8 // indirect
|
||||
require code.rocket9labs.com/tslocum/bei v0.0.0-20231223213316-ef6cb993c773 // indirect
|
||||
|
|
12
go.sum
12
go.sum
|
@ -1,8 +1,8 @@
|
|||
code.rocket9labs.com/tslocum/bei v0.0.0-20231222205835-c070d7c7d5f8 h1:QefJxcMg2aneCZuoHPpnDOTsing1mehImilbyyT3SwU=
|
||||
code.rocket9labs.com/tslocum/bei v0.0.0-20231222205835-c070d7c7d5f8/go.mod h1:tS60/VNAJphKvDBkSLQhKALa15msIAuWWfEKNc4oFZc=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231223081447-262d006c714c h1:ri5THzKvxE5WqAH/d/U6gXunHJx2cwYUWrer8YQ0QEk=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231223081447-262d006c714c/go.mod h1:pM1hNhG/vKgk4Ktpszv5duQ3gJMrawO6gwotpJjHxyE=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20231223084935-b3664645e2f7 h1:CPnLFa2K1ynCrElQ4YBNIYsa3eQAtlNPdcCO2nxNmc0=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20231223084935-b3664645e2f7/go.mod h1:xi5drJjaVuqa9P8GyRAQMsI6FpxXjwPrlxYoVbzYxdI=
|
||||
code.rocket9labs.com/tslocum/bei v0.0.0-20231223213316-ef6cb993c773 h1:cu3FKYfk5WQcuxMXrqghHAmriyFiRCZ/8aUqIKI9yLU=
|
||||
code.rocket9labs.com/tslocum/bei v0.0.0-20231223213316-ef6cb993c773/go.mod h1:tS60/VNAJphKvDBkSLQhKALa15msIAuWWfEKNc4oFZc=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231225075851-a2fb60cf355b h1:Wlzs+62I+INQf+iAks2KduLKSP0v3yi4mJdSNxLfu3w=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20231225075851-a2fb60cf355b/go.mod h1:pM1hNhG/vKgk4Ktpszv5duQ3gJMrawO6gwotpJjHxyE=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20231223213411-12f4416eafe1 h1:mG11OT0JA5/zwN/rB02NnSIdgXZ3NEtZrPhOOrbsg+A=
|
||||
code.rocket9labs.com/tslocum/tabula v0.0.0-20231223213411-12f4416eafe1/go.mod h1:ZvMo2xto5GUODvzLiTNEg5DjHoKULK+HGt8wfYHHq78=
|
||||
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
|
||||
nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
|
||||
|
|
Loading…
Reference in a new issue