Merge branch 'master' of github.com:jeena/GGS

This commit is contained in:
Kallfaktorn 2011-05-05 02:47:21 +02:00
commit 8712049ed0
3 changed files with 21 additions and 3 deletions

View file

@ -12,7 +12,7 @@ class Chat
print "Table token (empty for new): "
table_token = gets.chomp
@ggs_network = GGSNetwork.new(self, table_token)
@ggs_network.connect("ggs.jeena.net", 9000)
@ggs_network.connect("home.jeena.net", 9000)
end
def ggsNetworkReady(ggs_network, am_i_host)
@ -44,6 +44,7 @@ class Chat
case command
when "message" then message(args)
when "notice" then notice(args)
when "pong" then pong(args)
end
end
@ -59,8 +60,23 @@ class Chat
def input
message = gets.chomp
if message[0..5] == "/nick "
@ggs_network.sendCommand("/nick", message[6,-1])
elsif message == "/ping"
ping()
else
@ggs_network.sendCommand("message", message)
end
end
def ping
@start_ping = Time.now
@ggs_network.sendCommand("ping", @ggs_network.player_token)
end
def pong(id)
puts "<pong: " + (Time.now - @start_ping).to_s + ">"
end
end

View file

@ -3,6 +3,8 @@ function playerCommand(player_id, command, args) {
changeNick(player_id, args);
} else if(command == "message") {
message(player_id, args);
} else if(command == "ping") {
GGS.sendCommand(player_id, "pong", args);
}
}

View file

@ -7,7 +7,7 @@ class GGSNetwork
public
attr_accessor :delegate
attr_accessor :delegate, :player_token
def initialize(delegate, table_token="")
@table_token = table_token