Commit f5d31080 authored by 神楽坂玲奈's avatar 神楽坂玲奈

nbx初步,大厅广播

parent d5574ce4
...@@ -24,7 +24,7 @@ class NBX < Iduel ...@@ -24,7 +24,7 @@ class NBX < Iduel
@conn_hall.send("#{head}|#{args.join(',')}", 0, user ? user.host : '<broadcast>', Port) @conn_hall.send("#{head}|#{args.join(',')}", 0, user ? user.host : '<broadcast>', Port)
end end
def login(username) def login(username)
send(nil, 'USERONLINE', username) send(nil, 'USERONLINE', username, 1)
@user = User.new(username, 'localhost') @user = User.new(username, 'localhost')
end end
def connect(server, port=Port) def connect(server, port=Port)
......
...@@ -13,12 +13,18 @@ class NBX::Event ...@@ -13,12 +13,18 @@ class NBX::Event
case $1 case $1
when "USERONLINE" when "USERONLINE"
NBX::Event::USERONLINE NBX::Event::USERONLINE
when "Query"
end.new($2, host) end.new($2, host)
end end
end end
class NBX::Event::USERONLINE < NBX::Event class NBX::Event::USERONLINE < NBX::Event
attr_reader :user#, :session attr_reader :user#, :session
def initialize(info, host) def initialize(info, host)
@user = NBX::User.new(info, host)
username, need_reply = info.split(',')
@user = NBX::User.new(username, host)
@need_reply = need_reply == "1"
p info, need_reply, @need_reply, @need_reply and @user != $nbx.user
$nbx.send(@user, 'USERONLINE', $nbx.user.name) if @need_reply and @user != $nbx.user
end end
end end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment