Class: ChatHandler

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

Instance Method Summary collapse

Methods inherited from Handler

#dispose, #initialize

Constructor Details

This class inherits a constructor from Handler

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