Beaming Scene Service  2.0
RakNet wrapper for managing data communications between multiple Beaming clients
PHPConnections Class Reference

Use PHPConnections as a C++ client to Connections.php. More...

#include <PHPConnections.h>

List of all members.

Public Member Functions

 PHPConnections ()
virtual ~PHPConnections ()
void Init (HTTPConnection *_http, const char *_path)
void SetField (RakNet::RakString columnName, RakNet::RakString value)
unsigned int GetFieldCount (void) const
 Returns the number of fields set with SetField()
void GetField (unsigned int index, RakNet::RakString &columnName, RakNet::RakString &value)
void SetFields (DataStructures::Table *table)
void ClearFields (void)
 Clear all fields.
void UploadTable (RakNet::RakString uploadPassword, RakNet::RakString clientName, unsigned short clientPort, bool autoRepost)
void DownloadTable (RakNet::RakString downloadPassword)
void UploadAndDownloadTable (RakNet::RakString uploadPassword, RakNet::RakString downloadPassword, RakNet::RakString clientName, unsigned short clientPort, bool autoRepost)
HTTPReadResult ProcessHTTPRead (RakNet::RakString httpRead)
const DataStructures::Table * GetLastDownloadedTable (void) const
void Update (void)
 Call this periodically - it will handle connection states and refreshing updates to the server.

Detailed Description

Use PHPConnections as a C++ client to Connections.php.

PHPConnections works with the HTTPConnection class (which works with the TCPInterface class) in order to communiate with Connections.php

Definition at line 40 of file PHPConnections.h.


Constructor & Destructor Documentation

Definition at line 43 of file PHPConnections.cpp.

Definition at line 48 of file PHPConnections.cpp.


Member Function Documentation

void PHPConnections::ClearFields ( void  )

Clear all fields.

Definition at line 99 of file PHPConnections.cpp.

void PHPConnections::DownloadTable ( RakNet::RakString  downloadPassword)

Send a download request to the PHP server. On success: 1. HTTPConnection::HasRead() will return true. 2. Pass the value returned by HTTPConnection::Read() to PHPConnections::ProcessHTTPRead(). 3. The return value of PHPConnections::ProcessHTTPRead() will be HTTP_RESULT_GOT_TABLE or HTTP_RESULT_EMPTY 4. On HTTP_RESULT_GOT_TABLE, use GetLastDownloadedTable() to read the results.

Parameters:
[in]downloadPasswordThe download password set in the PHP page itself when you first uploaded and viewed it in the webpage.

Definition at line 119 of file PHPConnections.cpp.

void PHPConnections::GetField ( unsigned int  index,
RakNet::RakString &  columnName,
RakNet::RakString &  value 
)

Returns a field set with SetField()

Parameters:
[in]indexThe 0 based index into the field list
[out]columnNameThe columnName parameter passed to SetField()
[out]valueThe value parameter passed to SetField()

Definition at line 76 of file PHPConnections.cpp.

unsigned int PHPConnections::GetFieldCount ( void  ) const

Returns the number of fields set with SetField()

Definition at line 72 of file PHPConnections.cpp.

const DataStructures::Table * PHPConnections::GetLastDownloadedTable ( void  ) const

Returns the last value returned from ProcessHTTPString Default columns are "__CLIENT_NAME", "__CLIENT_PORT", "_System_Address"

Returns:
The table created by parsing httpString

Definition at line 246 of file PHPConnections.cpp.

void PHPConnections::Init ( HTTPConnection *  _http,
const char *  _path 
)

Associate PHPConnections with the HTTPConnection class it will communicate through

Parameters:
[in]_httpThe instance of HTTP connection we will communicate through
[in]_pathThe path to the PHP file on the remote server. For example, if the path is mysite.com/raknet/Connections.php then you would enter raknet/Connections.php

Definition at line 51 of file PHPConnections.cpp.

HTTPReadResult PHPConnections::ProcessHTTPRead ( RakNet::RakString  httpRead)

When HTTPConnection::ProcessDataPacket() returns true, and not an error, pass HTTPConnection::Read() to this function The message will be parsed into DataStructures::Table, and a copy stored internally which can be retrieved by GetLastDownloadedTable();

Parameters:
[in]packetDataReturned from HTTPInterface::Read()
Returns:
One of the values for HTTPReadResult

Definition at line 142 of file PHPConnections.cpp.

void PHPConnections::SetField ( RakNet::RakString  columnName,
RakNet::RakString  value 
)

Set a parameter (these are passed to the server) To delete a column, just pass an empty string for value Store the client name and port with UploadTable, rather than SetField, as these columns are required and use reserved column names

Parameters:
[in]columnNameThe name of the column to store
[in]valueWhat value to hold for the uploaded row (only one row can be uploaded at a time)

Definition at line 57 of file PHPConnections.cpp.

void PHPConnections::SetFields ( DataStructures::Table *  table)

Set all parameters at once from a table

Parameters:
[in]tableA table containing the values you want to send. Note that all values are stored as strings in PHP

Definition at line 82 of file PHPConnections.cpp.

void PHPConnections::Update ( void  )

Call this periodically - it will handle connection states and refreshing updates to the server.

Definition at line 278 of file PHPConnections.cpp.

void PHPConnections::UploadAndDownloadTable ( RakNet::RakString  uploadPassword,
RakNet::RakString  downloadPassword,
RakNet::RakString  clientName,
unsigned short  clientPort,
bool  autoRepost 
)

Same as calling DownloadTable immediately followed by UploadTable, except only the download result is returned

Parameters:
[in]uploadPasswordThe upload password set in the PHP page itself when you first uploaded and viewed it in the webpage.
[in]downloadPasswordThe download password set in the PHP page itself when you first uploaded and viewed it in the webpage.
[in]clientNameEvery entry must have a client name. Pass it here.
[in]clientPortEvery entry must have a client port. Pass it here. The IP address will be stored automatically, or you can manually set it by passing a field named _System_Address
[in]autoRepostTables must be uploaded every 60 seconds or they get dropped. Set autoRepost to true to automatically reupload the most recent table.

Definition at line 125 of file PHPConnections.cpp.

void PHPConnections::UploadTable ( RakNet::RakString  uploadPassword,
RakNet::RakString  clientName,
unsigned short  clientPort,
bool  autoRepost 
)

Upload the values set with SetFields() or SetField() On success: 1. HTTPConnection::HasRead() will return true. 2. Pass the value returned by HTTPConnection::Read() to PHPConnections::ProcessHTTPRead(). 3. The return value of PHPConnections::ProcessHTTPRead() will be HTTP_RESULT_EMPTY

Parameters:
[in]uploadPasswordThe upload password set in the PHP page itself when you first uploaded and viewed it in the webpage.
[in]clientNameEvery entry must have a client name. Pass it here.
[in]clientPortEvery entry must have a client port. Pass it here. The IP address will be stored automatically, or you can manually set it by passing a field named _System_Address
[in]autoRepostTables must be uploaded every 60 seconds or they get dropped. Set autoRepost to true to automatically reupload the most recent table.

Definition at line 105 of file PHPConnections.cpp.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator Defines