Class: SocketIo::Packet::ErrorPacket

Inherits:
SocketIo::Packet show all
Defined in:
lib/socket.io/packet/error_packet.rb

Constant Summary collapse

REASONS =
['transport not supported', 'client not handshaken', 'unauthorized']
ADVICE =
%w{reconnect}

Constants inherited from SocketIo::Packet

PACKET_REGEX, PACKET_TYPES

Instance Attribute Summary

Attributes inherited from SocketIo::Packet

#ack, #data, #endpoint, #id

Instance Method Summary collapse

Methods inherited from SocketIo::Packet

#ackdata?, #initialize, #json, parse, parse_json

Constructor Details

This class inherits a constructor from SocketIo::Packet

Instance Method Details

#from_pieces(pieces) ⇒ Object



7
8
9
10
11
# File 'lib/socket.io/packet/error_packet.rb', line 7

def from_pieces(pieces)
  sub_pieces = data.split('+');
  self.reason = REASONS[sub_pieces[0]] || '';
  self.advice = ADVICE[sub_pieces[1]] || '';
end

#to_sObject



15
16
17
18
19
20
21
# File 'lib/socket.io/packet/error_packet.rb', line 15

def to_s
  payload = nil
  if reason != '' || advice != ''
    payload = reason + (advice != '' ? ('+' + advice) : '')
  end
  super payload
end

#type_idObject



13
# File 'lib/socket.io/packet/error_packet.rb', line 13

def type_id; 7; end