Merge branch 'master' of github.com:jeena/GGS
This commit is contained in:
commit
8712049ed0
3 changed files with 21 additions and 3 deletions
|
@ -12,7 +12,7 @@ class Chat
|
||||||
print "Table token (empty for new): "
|
print "Table token (empty for new): "
|
||||||
table_token = gets.chomp
|
table_token = gets.chomp
|
||||||
@ggs_network = GGSNetwork.new(self, table_token)
|
@ggs_network = GGSNetwork.new(self, table_token)
|
||||||
@ggs_network.connect("ggs.jeena.net", 9000)
|
@ggs_network.connect("home.jeena.net", 9000)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ggsNetworkReady(ggs_network, am_i_host)
|
def ggsNetworkReady(ggs_network, am_i_host)
|
||||||
|
@ -44,6 +44,7 @@ class Chat
|
||||||
case command
|
case command
|
||||||
when "message" then message(args)
|
when "message" then message(args)
|
||||||
when "notice" then notice(args)
|
when "notice" then notice(args)
|
||||||
|
when "pong" then pong(args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,8 +60,23 @@ class Chat
|
||||||
|
|
||||||
def input
|
def input
|
||||||
message = gets.chomp
|
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)
|
@ggs_network.sendCommand("message", message)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ function playerCommand(player_id, command, args) {
|
||||||
changeNick(player_id, args);
|
changeNick(player_id, args);
|
||||||
} else if(command == "message") {
|
} else if(command == "message") {
|
||||||
message(player_id, args);
|
message(player_id, args);
|
||||||
|
} else if(command == "ping") {
|
||||||
|
GGS.sendCommand(player_id, "pong", args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ class GGSNetwork
|
||||||
|
|
||||||
public
|
public
|
||||||
|
|
||||||
attr_accessor :delegate
|
attr_accessor :delegate, :player_token
|
||||||
|
|
||||||
def initialize(delegate, table_token="")
|
def initialize(delegate, table_token="")
|
||||||
@table_token = table_token
|
@table_token = table_token
|
||||||
|
|
Reference in a new issue