added serverLog to API

This commit is contained in:
Jeena Paradies 2011-05-05 12:51:10 +02:00
parent 4abcdd5579
commit 08e086084c
4 changed files with 14 additions and 15 deletions

View file

@ -26,7 +26,7 @@ class Chat
table_token = gets.chomp unless @is_bot table_token = gets.chomp unless @is_bot
@ggs_network = GGSNetwork.new(self, table_token) @ggs_network = GGSNetwork.new(self, table_token)
@ggs_network.connect("ggs.jeena.net", 9000) @ggs_network.connect("localhost", 9000)
end end
def ggsNetworkReady(ggs_network, am_i_host) def ggsNetworkReady(ggs_network, am_i_host)
@ -125,6 +125,8 @@ class Chat
toggle_log toggle_log
elsif message == "/help" elsif message == "/help"
help help
elsif message == "/exit"
exit
elsif message == "/ignore" elsif message == "/ignore"
@ignore = @ignore ? false : true @ignore = @ignore ? false : true
if @ignore if @ignore
@ -181,6 +183,7 @@ class Chat
puts "| /bots | stop all bots |" puts "| /bots | stop all bots |"
puts "| /log | toggle logging |" puts "| /log | toggle logging |"
puts "| /ignore | toggle ignoring everyone |" puts "| /ignore | toggle ignoring everyone |"
puts "| /exit | exit chat |"
puts "| /help | show this help |" puts "| /help | show this help |"
puts "+-----------------------------------------------+" puts "+-----------------------------------------------+"
end end

View file

@ -4,7 +4,7 @@ function playerCommand(player_id, command, args) {
} else if(command == "message") { } else if(command == "message") {
message(player_id, args); message(player_id, args);
} else if(command == "ping") { } else if(command == "ping") {
GGS.sendCommand(player_id, "pong", args); GGS.sendCommand(player_id, "pong", GGS.serverInfo() + "");
} }
} }
@ -13,7 +13,7 @@ function changeNick(player_id, nick) {
GGS.localStorage.setItem("nick_" + player_id, nick); GGS.localStorage.setItem("nick_" + player_id, nick);
if (!old_nick) { if (!old_nick) {
GGS.sendCommandToAll("notice", nick + " joined ä"); GGS.sendCommandToAll("notice", nick + " joined");
} else { } else {
GGS.sendCommandToAll("notice", old_nick + " is now called " + nick); GGS.sendCommandToAll("notice", old_nick + " is now called " + nick);
} }

View file

@ -90,9 +90,13 @@ expose(Global, Table) ->
ggs_table:send_command(Table, Player, {Command, Args}) ggs_table:send_command(Table, Player, {Command, Args})
end}, end},
{"sendCommandToAll", fun(#erlv8_fun_invocation{}, [Command, Args])-> {"sendCommandToAll", fun(#erlv8_fun_invocation{}, [Command, Args])->
erlang:display(Args),
ggs_table:notify_all_players(Table, {Command, Args}) ggs_table:notify_all_players(Table, {Command, Args})
end} end},
{"serverInfo", fun(#erlv8_fun_invocation{}, []) ->
{ok, TableList} = ggs_table:get_player_list(Table),
integer_to_list(length(TableList))
end}
%{"log", fun(#erlv8_fun_invocation{}, [Arg]) -> erlang:display(Arg) end }
%{"setTimeout", fund(#erlv8_fun_invocation{}, [Time, FunctionName])-> setTimeout(Time, FunctionName) end} %{"setTimeout", fund(#erlv8_fun_invocation{}, [Time, FunctionName])-> setTimeout(Time, FunctionName) end}
])). ])).

View file

@ -37,16 +37,8 @@ init(_Args) ->
handle_cast({add_one, Type}, St) -> handle_cast({add_one, Type}, St) ->
case Type of case Type of
server -> NewSt = #ate { server -> NewSt = St#ate { server_messages = St#ate.server_messages + 1 };
server_messages = St#ate.server_messages + 1, client -> NewSt = St#ate { client_messages = St#ate.client_messages + 1 }
client_messages = St#ate.client_messages,
stats = St#ate.stats
};
client -> NewSt = #ate {
server_messages = St#ate.server_messages,
client_messages = St#ate.client_messages + 1,
stats = St#ate.stats
}
end, end,
{noreply, NewSt}; {noreply, NewSt};