Class: SocketIo::Packet::AckPacket

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

Constant Summary

Constants inherited from SocketIo::Packet

PACKET_REGEX, PACKET_TYPES

Instance Attribute Summary collapse

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 Attribute Details

#ack_idObject

Returns the value of attribute ack_id.



6
7
8
# File 'lib/socket.io/packet/ack_packet.rb', line 6

def ack_id
  @ack_id
end

#argsObject

Returns the value of attribute args.



6
7
8
# File 'lib/socket.io/packet/ack_packet.rb', line 6

def args
  @args
end

Instance Method Details

#parse_pieces(pieces) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/socket.io/packet/ack_packet.rb', line 8

def parse_pieces(pieces)
  if sub_pieces = data =~ /^([0-9]+)(\+)?(.*)/
    self.ack_id = sub_pieces[1];
    self.args = [];

    if sub_pieces[3]
      self.args = Packet.parse_json(sub_pieces[3]) || [];
    end
  end
end

#to_sObject



21
22
23
24
25
# File 'lib/socket.io/packet/ack_packet.rb', line 21

def to_s
  payload = ack_id.to_s
  payload += '+' + args.to_json if args
  super payload
end

#type_idObject



19
# File 'lib/socket.io/packet/ack_packet.rb', line 19

def type_id; 6; end