OpenTTDLib
[ class tree: OpenTTDLib ] [ index: OpenTTDLib ] [ all elements ]

Class: OpenTTDLibPacket

Source Location: /includes/OpenTTDLibPacket.php

Class Overview


OpenTTDLibPacket provides OpenTTDLib with means for reading from and writing to a udp packet


Author(s):

Constants

Methods



Class Details

[line 32]
OpenTTDLibPacket provides OpenTTDLib with means for reading from and writing to a udp packet



Tags:

author:  TrueLight <truelight@openttd.org>
author:  dihedral <dihedral@codecubes.org>
usedby:  OpenTTDLib::processPacket()
license:  GNU General Public License v2
usedby:  OpenTTDLib::RecvData() - to handle storeing the packet and to read data from


[ Top ]


Class Methods


constructor __construct [line 81]

OpenTTDLibPacket __construct( [string $data = ""], [integer $size = 0], [integer $pos = 0])

initiate the packet instance



Tags:

access:  public


Parameters:

string   $data   the packet data
integer   $size   size of the packet
integer   $pos   postition next read will start at

[ Top ]

method getData [line 339]

string getData( )

get the actual packet data



Tags:

access:  public


[ Top ]

method getPos [line 329]

integer getPos( )

get the postion for next read



Tags:

access:  public


[ Top ]

method getSize [line 319]

integer getSize( )

get the size of the packet



Tags:

access:  public


[ Top ]

method NetworkSend_Init [line 102]

OpenTTDLibPacket &NetworkSend_Init( integer $type)

inialize a packet to add data too for later sending



Tags:

return:  instance
access:  public


Parameters:

integer   $type   packet type, one of OPENTTDLIB_PACKET_UPP_CLIENT_FIND_SERVER or OPENTTDLIB_PACKET_UDP_CLIENT_DETAIL_INFO

[ Top ]

method PrepareToSend [line 115]

void PrepareToSend( )

write packetsize to the packet itself (first 2 bytes)



Tags:

access:  public


[ Top ]

method ReadRawPacketSize [line 297]

void ReadRawPacketSize( )

resets the internal position pointer to 0 and readas packet size from packet (first 2 bytes)



Tags:

access:  public


[ Top ]

method Recv_string [line 277]

string Recv_string( )

read the next few bytes, process and return a value we can work with



Tags:

access:  public


[ Top ]

method Recv_uint8 [line 192]

integer Recv_uint8( )

read the next few byets, process and return a value we can work with



Tags:

access:  public


[ Top ]

method Recv_uint16 [line 200]

integer Recv_uint16( [boolean $switch_endian = false])

read the next few byets, process and return a value we can work with




Tags:

access:  public


Parameters:

boolean   $switch_endian   reverse endianness

[ Top ]

method Recv_uint32 [line 219]

integer Recv_uint32( [boolean $switch_endian = false])

read the next few byets, process and return a value we can work with




Tags:

access:  public


Parameters:

boolean   $switch_endian   reverse endianness

[ Top ]

method Recv_uint64 [line 251]

string Recv_uint64( )

64 bit integer handling using BCMath extentions

read the next few bytes, process and return a value we can work with

please use the BCMath functions for handling 64 bit integers
thanks to eekee, Rubidium and SmatZ




Tags:

link:  http://www.php.net/manual/en/ref.bc.php
access:  public


[ Top ]

method resetPos [line 349]

void resetPos( )

set the internal pointer back to 0



Tags:

access:  public


[ Top ]

method Send_string [line 177]

void Send_string( string $s)

append data to the packet for sending




Tags:

access:  public


Parameters:

string   $s   String to append to packet

[ Top ]

method Send_uint8 [line 133]

void Send_uint8( integer $d)

append data to the packet for sending




Tags:

access:  public


Parameters:

integer   $d   integer to append to packet

[ Top ]

method Send_uint16 [line 142]

void Send_uint16( integer $d, [boolean $switch_endian = false])

append data to the packet for sending




Tags:

access:  public


Parameters:

integer   $d   integer to append to packet
boolean   $switch_endian   reverse endianness

[ Top ]

method Send_uint32 [line 160]

void Send_uint32( integer $d, [boolean $switch_endian = false])

append data to the packet for sending




Tags:

access:  public


Parameters:

integer   $d   integer to append to packet
boolean   $switch_endian   reverse endianness

[ Top ]

method sizeOK [line 308]

bool sizeOK( )

compare actual packet size with claimed packet size



Tags:

return:  false if the packet sizes are not the same
access:  public


[ Top ]

method __sleep [line 359]

array __sleep( )

binary safe storing the packet data



Tags:

return:  class variables to serialize
access:  public


[ Top ]

method __wakeup [line 370]

void __wakeup( )

binary safe restoring the packet data



Tags:

access:  public


[ Top ]


Class Constants

SEND_MTU =  1460

[line 48]

size of a packet


[ Top ]

UDP_CLIENT_DETAIL_INFO =  2

[line 39]

upd packet enum as found in network_udp.c (0.5) or src/network/core/udp.h (trunk)


[ Top ]

UDP_CLIENT_FIND_SERVER =  0

[line 37]

upd packet enum as found in network_udp.c (0.5) or src/network/core/udp.h (trunk)


[ Top ]

UDP_CLIENT_GET_NEWGRFS =  9

[line 41]

upd packet enum as found in network_udp.c (0.5) or src/network/core/udp.h (trunk)


[ Top ]

UDP_SERVER_DETAIL_INFO =  3

[line 40]

upd packet enum as found in network_udp.c (0.5) or src/network/core/udp.h (trunk)


[ Top ]

UDP_SERVER_NEWGRFS =  10

[line 42]

upd packet enum as found in network_udp.c (0.5) or src/network/core/udp.h (trunk)


[ Top ]

UDP_SERVER_RESPONSE =  1

[line 38]

upd packet enum as found in network_udp.c (0.5) or src/network/core/udp.h (trunk)


[ Top ]



Documentation generated on Wed, 29 Apr 2009 23:33:50 +0200 by phpDocumentor 1.4.2