shogi-server source
Revisão | 7cd512b50be019cee0d9c000716be2277d50743f (tree) |
---|---|
Hora | 2020-10-04 23:05:22 |
Autor | Mizar <mizar.jp@gmai...> |
Commiter | Mizar |
Improved timeout detection for space command
Support for clients that perform SP+LF keep-alive, likes Shogidokoro (version 4.7.1+Test4).
@@ -28,7 +28,7 @@ module ShogiServer | ||
28 | 28 | def Command.factory(str, player, time=Time.now) |
29 | 29 | cmd = nil |
30 | 30 | case str |
31 | - when "", /^%[^%]/, :timeout | |
31 | + when "", /^\s*$/, /^%[^%]/, :timeout | |
32 | 32 | cmd = SpecialCommand.new(str, player) |
33 | 33 | when /^[\+\-][^%]/ |
34 | 34 | cmd = MoveCommand.new(str, player) |
@@ -108,8 +108,6 @@ module ShogiServer | ||
108 | 108 | new_buoy_game = nil |
109 | 109 | nth_move = nil |
110 | 110 | cmd = ForkCommand.new(str, player, source_game, new_buoy_game, nth_move) |
111 | - when /^\s*$/ | |
112 | - cmd = SpaceCommand.new(str, player) | |
113 | 111 | when /^%%%[^%]/ |
114 | 112 | # TODO: just ignore commands specific to 81Dojo. |
115 | 113 | # Need to discuss with 81Dojo people. |
@@ -172,7 +170,7 @@ module ShogiServer | ||
172 | 170 | end |
173 | 171 | end |
174 | 172 | |
175 | - # Command like "%TORYO", :timeout, or keep alive | |
173 | + # Command like "%TORYO", :timeout, space, or keep alive | |
176 | 174 | # |
177 | 175 | # Keep Alive is an application-level protocol. Whenever the server receives |
178 | 176 | # an LF, it sends back an LF. Note that the 30 sec rule (client may not send |
@@ -191,6 +189,9 @@ module ShogiServer | ||
191 | 189 | @player.write_safe("\n") |
192 | 190 | # Fall back to :timeout to check the game gets timed up |
193 | 191 | @str = :timeout |
192 | + elsif /^\s+$/ =~ @str | |
193 | + # Fall back to :timeout to check the game gets timed up | |
194 | + @str = :timeout | |
194 | 195 | end |
195 | 196 | |
196 | 197 | if (@player.status == "game") |
@@ -673,19 +674,6 @@ module ShogiServer | ||
673 | 674 | end |
674 | 675 | end |
675 | 676 | |
676 | - # Command for a space | |
677 | - # | |
678 | - class SpaceCommand < Command | |
679 | - def initialize(str, player) | |
680 | - super | |
681 | - end | |
682 | - | |
683 | - def call | |
684 | - ## ignore null string | |
685 | - return :continue | |
686 | - end | |
687 | - end | |
688 | - | |
689 | 677 | # Command for an error |
690 | 678 | # |
691 | 679 | class ErrorCommand < Command |