Main   Class List   Namespace List   Wiki

TCPObject Class Reference
[Platform]

Allows communications between the game and a server using TCP/IP protocols. More...

Inheritance diagram for TCPObject:
Inheritance graph
[legend]

List of all members.

Public Member Functions

void connect (string address)
 Connect to the given address.
void disconnect ()
 Disconnect from whatever this TCPObject is currently connected to, if anything.
void listen (int port)
 Start listening on the specified port for connections.
void send (string data)
 Transmits the data string to the server.
Callbacks

void onConnected ()
 Called whenever a connection is established with a server.
void onConnectFailed ()
 Called whenever a connection has failed to be established with a server.
void onConnectionRequest (string address, string ID)
 Called whenever a connection request is made.
void onDisconnect ()
 Called whenever the TCPObject disconnects from whatever it is currently connected to.
void onDNSFailed ()
 Called whenever the DNS has failed to resolve.
void onDNSResolved ()
 Called whenever the DNS has been resolved.
void onLine (string line)
 Called whenever a line of data is sent from the server connected to this TCPObject to the game client.

Detailed Description

Allows communications between the game and a server using TCP/IP protocols.

Example:
// Create a an TCP object for communications
%newTCPObj = new TCPObject();

// Transmit a send command with a specific server. Parameters are transmitted to the server as strings, one at a time.
%newTCPObj.send(""GET " @ $RSSFeed::serverURL @ " HTTP/1.0
Host: " @ $RSSFeed::serverName @ "\nUser-Agent: " @ $RSSFeed::userAgent @ "\n\r\n\r\n"");

// Callback from the engine. Called when the TCPObject receives a response from the server, along with return data.
function TCPObject.onLine(%this,%returnLine);
{
   echo("Data returned from the server = " @ %returnLine );
};

// DNS Resolved Response
TCPObject::onDNSResolved(%this)
{
   // Do Code When DNS Resolved
}

// DNS Failed Resonse
TCPObject::onDNSFailed(%this)
{
   // Do Code When DNS Failed
}

// Connected to Server Response
TCPObject::onConnected(%this)
{
   // Do Code When Connection Occurs
}

// Connection to Server Failed
TCPObject::onConnectFailed(%this)
{
   // Do Code When Connection Failed
}

// Disconnected from Server
TCPObject::onDisconnect(%this)
{
   // Do Code When Disconnected
}

Member Function Documentation

void TCPObject::onConnected (  ) 

Called whenever a connection is established with a server.

void TCPObject::onConnectFailed (  ) 

Called whenever a connection has failed to be established with a server.

void TCPObject::onConnectionRequest ( string  address,
string  ID 
)

Called whenever a connection request is made.

Parameters:
address Server address to connect to.
ID Connection ID
void TCPObject::onDisconnect (  ) 

Called whenever the TCPObject disconnects from whatever it is currently connected to.

void TCPObject::onDNSFailed (  ) 

Called whenever the DNS has failed to resolve.

void TCPObject::onDNSResolved (  ) 

Called whenever the DNS has been resolved.

void TCPObject::onLine ( string  line  ) 

Called whenever a line of data is sent from the server connected to this TCPObject to the game client.

Parameters:
line Data sent from the server.


Copyright © GarageGames, LLC. All Rights Reserved.