kodi
Public Member Functions | Public Attributes | List of all members
python.xbmcclient.Packet Class Reference

Packet Classes. More...

Inheritance diagram for python.xbmcclient.Packet:
Inheritance graph
[legend]

Public Member Functions

def __init__ (self)
 
def append_payload (self, blob)
 
def set_payload (self, payload)
 
def num_packets (self)
 
def get_header (self, packettype=-1, seq=1, maxseq=1, payload_size=0)
 
def get_payload_size (self, seq)
 
def get_udp_message (self, packetnum=1)
 
def send (self, sock, addr, uid=UNIQUE_IDENTIFICATION)
 

Public Attributes

 sig
 
 minver
 
 majver
 
 seq
 
 maxseq
 
 payloadsize
 
 uid
 
 reserved
 
 payload
 

Detailed Description

Packet Classes.

Base class that implements a single event packet.

 - Generic packet structure (maximum 1024 bytes per packet)
 - Header is 32 bytes long, so 992 bytes available for payload
 - large payloads can be split into multiple packets using H4 and H5
   H5 should contain total no. of packets in such a case
 - H6 contains length of P1, which is limited to 992 bytes
 - if H5 is 0 or 1, then H4 will be ignored (single packet msg)
 - H7 must be set to zeros for now

     -----------------------------
     | -H1 Signature ("XBMC")    | - 4  x CHAR                4B
     | -H2 Version (eg. 2.0)     | - 2  x UNSIGNED CHAR       2B
     | -H3 PacketType            | - 1  x UNSIGNED SHORT      2B
     | -H4 Sequence number       | - 1  x UNSIGNED LONG       4B
     | -H5 No. of packets in msg | - 1  x UNSIGNED LONG       4B
     | -H7 Client's unique token | - 1  x UNSIGNED LONG       4B
     | -H8 Reserved              | - 10 x UNSIGNED CHAR      10B
     |---------------------------|
     | -P1 payload               | -
     -----------------------------

Member Function Documentation

◆ append_payload()

def python.xbmcclient.Packet.append_payload (   self,
  blob 
)
Append to existing payload

Arguments:
blob -- binary data to append to the current payload

◆ get_header()

def python.xbmcclient.Packet.get_header (   self,
  packettype = -1,
  seq = 1,
  maxseq = 1,
  payload_size = 0 
)
Construct a header and return as string

Keyword arguments:
packettype -- valid packet types are PT_HELO, PT_BYE, PT_BUTTON,
      PT_MOUSE, PT_PING, PT_BORADCAST, PT_NOTIFICATION,
      PT_BLOB, PT_DEBUG
seq -- the sequence of this packet for a multi packet message
       (default 1)
maxseq -- the total number of packets for a multi packet message
  (default 1)
payload_size -- the size of the payload of this packet (default 0)

◆ get_payload_size()

def python.xbmcclient.Packet.get_payload_size (   self,
  seq 
)
Returns the calculated payload size for the particular packet

Arguments:
seq -- the sequence number

◆ get_udp_message()

def python.xbmcclient.Packet.get_udp_message (   self,
  packetnum = 1 
)
Construct the UDP message for the specified packetnum and return
as string

Keyword arguments:
packetnum -- the packet no. for which to construct the message
     (default 1)

◆ num_packets()

def python.xbmcclient.Packet.num_packets (   self)
Return the number of packets required for payload 

◆ send()

def python.xbmcclient.Packet.send (   self,
  sock,
  addr,
  uid = UNIQUE_IDENTIFICATION 
)
Send the entire message to the specified socket and address.

Arguments:
sock -- datagram socket object (socket.socket)
addr -- address, port pair (eg: ("127.0.0.1", 9777) )
uid  -- unique identification

◆ set_payload()

def python.xbmcclient.Packet.set_payload (   self,
  payload 
)
Set the payload for this packet

Arguments:
payload -- binary data that contains the payload

The documentation for this class was generated from the following file: