Class: ChatHandler

Inherits:
Handler
  • Object
show all
Defined in:
lib/handler/chat_handler.rb

Instance Method Summary collapse

Instance Method Details

#recv(server, connection, packet) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/handler/chat_handler.rb', line 2

def recv(server,connection,packet)
	case packet.id
		when Protocol::CHAT
			#puts "[#{packet["sender"]}] : #{packet["msg"]}"
			
			reply = Packet.new
			reply.id = Protocol::CHAT
			reply["sender"] = packet["sender"]
			reply["msg"] = packet["msg"]
			
			server.pubsub.publish(packet.ch, reply)
	end
end