@eol = "\m" # favorite eol code
@game = nil
@game_name = ""
- @mytime = Total_Time
+ @mytime = Total_Time # set in start method also
@sente = nil
@watchdog_thread = nil
end
def run
+ write_safe(sprintf("LOGIN:%s OK\n", @name))
if (@protocol != "CSA")
log_message(sprintf("user %s run in %s mode", @name, @protocol))
write_safe(sprintf("##[LOGIN] +OK %s\n", @protocol))
@game.gote.status = "game"
end
else
- write_safe("## you are in %s status. AGREE is valid in agree_waiting status\n", @status)
+ write_safe("##[ERROR] you are in %s status. AGREE is valid in agree_waiting status\n", @status)
next
end
when /^%%HELP/
if ((@status == "connected") || (@status == "game_waiting"))
@status = "game_waiting"
else
- write_safe(sprintf("## you are in %s status. GAME is valid in connected or game_waiting status\n", @status))
+ write_safe(sprintf("##[ERROR] you are in %s status. GAME is valid in connected or game_waiting status\n", @status))
next
end
@status = "game_waiting"
end
buf.push("##[WHO] +OK\n")
write_safe(buf.join)
- when /^%%LOGOUT/
+ when /^LOGOUT/
+ write_safe("LOGOUT:completed\n")
finish
return
else
- write_safe(sprintf("## unknown command %s\n", str))
+ write_safe(sprintf("##[ERROR] unknown command %s\n", str))
end
ensure
$mutex.unlock
log_message(sprintf("game started %s %s %s", game_name, sente.name, gote.name))
@sente.write_safe(sprintf("START:%s\n", @id))
@gote.write_safe(sprintf("START:%s\n", @id))
+ @mytime = Total_Time
@start_time = Time::new
end
if (good_login?(str))
player = Player::new(str, client)
if (LEAGUE.duplicated?(player))
+ client.write_safe("LOGIN:incorrect" + eol)
client.write_safe(sprintf("username %s is already connected%s", player.name, eol))
client.close
Thread::kill(Thread::current)
LEAGUE.add(player)
break
else
+ client.write_safe("LOGIN:incorrect" + eol)
client.write_safe("type 'LOGIN name password' or 'LOGIN name password x1'" + eol)
client.close
Thread::kill(Thread::current)