Module: SocketIo::Websocket::Receiver
- Included in:
- SocketIo::Websocket
- Defined in:
- lib/socket.io/websocket/receiver.rb
Instance Method Summary collapse
- #handle_error(packet) ⇒ Object
- #handle_event(packet) ⇒ Object
- #handle_json(packet) ⇒ Object
- #handle_message(packet) ⇒ Object
- #handle_packet(data) ⇒ Object
Instance Method Details
#handle_error(packet) ⇒ Object
43 44 45 |
# File 'lib/socket.io/websocket/receiver.rb', line 43 def handle_error(packet) puts "Error from client: #{packet.inspect}" end |
#handle_event(packet) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/socket.io/websocket/receiver.rb', line 36 def handle_event(packet) json = packet.json name = json['name'] ack_args = send events[name].to_s, *json['args'] ack packet, args: ack_args end |
#handle_json(packet) ⇒ Object
31 32 33 34 |
# File 'lib/socket.io/websocket/receiver.rb', line 31 def handle_json(packet) ack_args = send events['message'], packet.json ack packet, args: ack_args end |
#handle_message(packet) ⇒ Object
26 27 28 29 |
# File 'lib/socket.io/websocket/receiver.rb', line 26 def (packet) ack_args = send events['message'], packet.data ack packet, args: ack_args end |
#handle_packet(data) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/socket.io/websocket/receiver.rb', line 6 def handle_packet(data) packet = SocketIo::Packet.parse(data) case packet.class.to_s when 'SocketIo::Packet::DisconnectPacket' then self.channel_id = nil when 'SocketIo::Packet::HeartbeatPacket' then self.channel_id = Time.now when 'SocketIo::Packet::MessagePacket' then (packet) when 'SocketIo::Packet::JsonPacket' then handle_json(packet) when 'SocketIo::Packet::EventPacket' then handle_event(packet) when 'SocketIo::Packet::AckPacket' then when 'SocketIo::Packet::ErrorPacket' then when 'SocketIo::Packet::NoopPacket' then end end |