|
@@ -72,8 +72,8 @@ def displaying(c, user)
|
|
|
end
|
|
|
#rescue Errno::EPIPE
|
|
|
rescue Exception => e
|
|
|
- #puts e.message
|
|
|
- #puts e.backtrace.inspect
|
|
|
+ puts e.message
|
|
|
+ puts e.backtrace.inspect
|
|
|
|
|
|
kill_conn(c, user, Thread.current)
|
|
|
put_log "Failed while writing to #{user}. Online users now: #{online_users.join(", ")}"
|
|
@@ -120,6 +120,7 @@ def online_users
|
|
|
|
|
|
end
|
|
|
|
|
|
+
|
|
|
def write_role(role, input, *exempts)
|
|
|
|
|
|
#find users with role
|
|
@@ -190,7 +191,10 @@ def inputting(user, input)
|
|
|
end
|
|
|
|
|
|
elsif cmd == "WHO"
|
|
|
- write_user(user, "WHO_RE #{online_users.join(", ")}")
|
|
|
+ online_users.each {|ouser|
|
|
|
+ write_user(user, "WHO_RE #{ouser} ROLES: #{$user_roles[user].join(", ")}")
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
elsif cmd == "PART"
|
|
|
write_user(user, "SYS Goodbye '#{user}'.")
|
|
@@ -291,7 +295,7 @@ def inputting(user, input)
|
|
|
else # of if allowed command
|
|
|
write_user(user, "SYS Command #{input} not allowed, your commands are: #{my_cmds(user).join(", ")}.")
|
|
|
end # of if allowed command
|
|
|
-
|
|
|
+ return true
|
|
|
end
|
|
|
|
|
|
def my_roles(user)
|
|
@@ -322,31 +326,39 @@ def thinking(c, user, t_display)
|
|
|
write_role($default_role, "JOINED User '#{user}' just joined the party.", user)
|
|
|
|
|
|
# reading the client input ... to write it somewhere, possibly to the client himself.
|
|
|
- begin
|
|
|
- input = nil
|
|
|
- while input != "PART" do
|
|
|
+ input = nil
|
|
|
+ while not input == "PART" do
|
|
|
+
|
|
|
+ begin
|
|
|
|
|
|
- begin
|
|
|
- status = Timeout::timeout(300) do
|
|
|
+ status = Timeout::timeout(300) do
|
|
|
+
|
|
|
+ begin
|
|
|
input = c.gets.chomp # waits for user input
|
|
|
- execution = inputting(user, input)
|
|
|
+ staying = inputting(user, input)
|
|
|
+ if not staying
|
|
|
+ put_log "'#{user}' parting normally.."
|
|
|
+ return false
|
|
|
+ end
|
|
|
+ rescue Exception => e
|
|
|
+ puts e.message
|
|
|
+ puts e.backtrace.inspect
|
|
|
+ put_log "'#{user}' lost connection."
|
|
|
+ #kill_conn(c, user, t_display)
|
|
|
+ return false
|
|
|
end
|
|
|
- rescue Timeout::Error => e
|
|
|
- write_user(user, "PING Still alive?") # if writing fails, then it may be a broken pipe .. so it will lose the connection and delete the user from the online user list.
|
|
|
- rescue Exception => e
|
|
|
- #puts e.message
|
|
|
- #puts e.backtrace.inspect
|
|
|
+
|
|
|
end
|
|
|
-
|
|
|
+
|
|
|
+ rescue Timeout::Error => e
|
|
|
+ write_user(user, "PING Still alive?") # if writing fails, then it may be a broken pipe .. so it will lose the connection and delete the user from the online user list.
|
|
|
+ rescue Exception => e
|
|
|
+ puts e.message
|
|
|
+ puts e.backtrace.inspect
|
|
|
end
|
|
|
- rescue Exception => e
|
|
|
- puts e.message
|
|
|
- puts e.backtrace.inspect
|
|
|
-
|
|
|
- put_log "#{user} lost connection."
|
|
|
|
|
|
end
|
|
|
-
|
|
|
+ return false
|
|
|
end
|
|
|
|
|
|
def pingtimer(c, user)
|
|
@@ -378,10 +390,9 @@ def spawn_server
|
|
|
begin
|
|
|
|
|
|
execution = thinking(c, user, t_user_display)
|
|
|
- if not execution
|
|
|
- # shut down the displaying thread and connection
|
|
|
- kill_conn(c, user, t_user_display)
|
|
|
- end
|
|
|
+
|
|
|
+ # shut down the displaying thread and connection
|
|
|
+ kill_conn(c, user, t_user_display)
|
|
|
|
|
|
rescue Exception => e
|
|
|
puts e.message
|