Introduction
Downloads
Documentation
Tutorials
Pixie Lite
Forum

Home

ClientConnection Class Reference

List of all members.


Public Member Functions

 ClientConnection ()
virtual ~ClientConnection ()
void Connect (const char *address, int port, bool useTCP, bool useUDP)
void ConnectSP ()
void ConnectHTTP (const char *address, int port, const char *resource="/")
void Disconnect ()
void Update (float deltaTime)
void TransmitTCP (const StaticBuffer &data)
void TransmitUDP (const StaticBuffer &data)
virtual void OnConnected ()=0
virtual void OnDisconnected ()=0
virtual void OnReceiveData (const StaticBuffer &data)=0

Friends

class ServerConnection

Detailed Description

Author:
Mattias Gustavsson

Definition at line 21 of file ClientConnection.h.


Constructor & Destructor Documentation

ClientConnection::ClientConnection (  ) 

Constructor

Definition at line 18 of file ClientConnection.cpp.

ClientConnection::~ClientConnection (  )  [virtual]

Destructor

Definition at line 31 of file ClientConnection.cpp.


Member Function Documentation

void ClientConnection::Connect ( const char *  address,
int  port,
bool  useTCP,
bool  useUDP 
)

Creates a client connection to the server on the specified address on the specified port, using TCP or UDP or both.

Parameters:
address IP or URL of server to connect to
port Port to connect on
useTCP Set to true to enable the TCP protocol
useUDP Set to true to enable the UDP protocol

Definition at line 65 of file ClientConnection.cpp.

void ClientConnection::ConnectSP (  ) 

Creates a client connection to the server using a memory buffer to transfer data. Used for single player modes.

Definition at line 79 of file ClientConnection.cpp.

void ClientConnection::ConnectHTTP ( const char *  address,
int  port,
const char *  resource = "/" 
)

Creates a client connection to the server using the HTTP protocol. A connection is actually established every time data is transferred, and is not kept alive in between. It can still be used in the same way as the other modes, and you only call ConnectHTTP once, and clean it up by calling Disconnect (actual connections are handled automatically).

Parameters:
address IP or URL of server to connect to
port Port to connect on
resource The server resource to connect to. This is typically the absolute path to a php file. Defaults to server root.

Definition at line 102 of file ClientConnection.cpp.

void ClientConnection::Disconnect (  ) 

Terminates the connection

Definition at line 126 of file ClientConnection.cpp.

void ClientConnection::Update ( float  deltaTime  ) 

Should be called every frame to process the connection

Definition at line 168 of file ClientConnection.cpp.

void ClientConnection::TransmitTCP ( const StaticBuffer data  ) 

Sends a data packet to the server using TCP protocol, ensuring that the data will arrive, and that data is received by the server in the same order as it was transmitted. TCP is slower than UDP, but reliable.

Parameters:
data Data to send

Definition at line 200 of file ClientConnection.cpp.

void ClientConnection::TransmitUDP ( const StaticBuffer data  ) 

Sends a data packet through UDP. It is not guaranteed to arrive at all, and if it does, data will not be received by the server in the same order as it was transmitted. UDP is faster than TCP, but unreliable.

Parameters:
data Data to send

Definition at line 221 of file ClientConnection.cpp.

virtual void ClientConnection::OnConnected (  )  [pure virtual]

When a connection has been established, this method is called. Implement it in your derived class to do what you want done when the client has been connected.

virtual void ClientConnection::OnDisconnected (  )  [pure virtual]

When a connection has been terminated, this methods called. Implement it in your derived class to do what you want done when the client has been disconnected.

virtual void ClientConnection::OnReceiveData ( const StaticBuffer data  )  [pure virtual]

Whenever a data package is received, this method is called. Implement it in your derived class to handle network messages from the server.

Parameters:
data Data being received


Friends And Related Function Documentation

friend class ServerConnection [friend]

Definition at line 137 of file ClientConnection.h.



Pixie University and the Pixie Game Engine is created and managed by Mattias Gustavsson.
Reproduction/republishing of any material on this site without permission is strictly prohibited.