Shadowrun: Awakened 29 September 2011 - Build 871
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes
RakNet::HTTPConnection Class Reference

Use HTTPConnection to communicate with a web server. More...

#include <HTTPConnection.h>

List of all members.

Classes

struct  BadResponse
 Encapsulates a raw HTTP response and response code. More...
struct  OutgoingCommand

Public Types

enum  ResponseCodes { NoBody = 1001, OK = 200, Deleted = 1002 }

Public Member Functions

void Get (const char *path)
SystemAddress GetServerAddress (void) const
 Returns the address of the server we are connected to.
int GetState (void) const
bool HasBadResponse (int *code, RakNet::RakString *data)
 Queued events of failed exchanges with the HTTP server.
bool HasRead (void) const
 Is there a Read result ready?
 HTTPConnection ()
 Returns a HTTP object associated with this tcp connection.
void Init (TCPInterface *_tcp, const char *host, unsigned short port=80)
bool IsBusy (void) const
 Returns false if the connection is not doing anything else.
HTTPConnectionoperator= (const HTTPConnection &rhs)
void Post (const char *path, const char *data, const char *_contentType="application/x-www-form-urlencoded")
void ProcessTCPPacket (Packet *packet)
RakNet::RakString Read (void)
void Update (void)
 Call periodically to do time-based updates.
virtual ~HTTPConnection ()

Static Public Member Functions

static void DestroyInstance (HTTPConnection *i)
static HTTPConnectionGetInstance (void)

Public Attributes

OutgoingCommand currentProcessingCommand
DataStructures::Queue
< OutgoingCommand
outgoingCommand

Private Types

enum  ConnectionState {
  CS_NONE, CS_DISCONNECTING, CS_CONNECTING, CS_CONNECTED,
  CS_PROCESSING
}

Private Member Functions

void CloseConnection ()

Private Attributes

DataStructures::Queue
< BadResponse
badResponses
enum
RakNet::HTTPConnection::ConnectionState 
connectionState
RakNet::RakString host
RakNet::RakString incomingData
unsigned short port
DataStructures::Queue
< RakNet::RakString
results
SystemAddress server
TCPInterfacetcp

Detailed Description

Start an instance of TCPInterface via the Start() command. Instantiate a new instance of HTTPConnection, and associate TCPInterface with the class in the constructor. Use Post() to send commands to the web server, and ProcessDataPacket() to update the connection with packets returned from TCPInterface that have the system address of the web server This class will handle connecting and reconnecting as necessary.

Note that only one Post() can be handled at a time.

Definition at line 43 of file HTTPConnection.h.


Member Enumeration Documentation

Enumerator:
CS_NONE 
CS_DISCONNECTING 
CS_CONNECTING 
CS_CONNECTED 
CS_PROCESSING 

Definition at line 140 of file HTTPConnection.h.

Results of HTTP requests. Standard response codes are < 999 ( define HTTP codes and our internal codes as needed )

Enumerator:
NoBody 
OK 
Deleted 

Definition at line 91 of file HTTPConnection.h.

{ NoBody=1001, OK=200, Deleted=1002 };

Constructor & Destructor Documentation

RakNet::HTTPConnection::HTTPConnection ( )
virtual RakNet::HTTPConnection::~HTTPConnection ( ) [virtual]

Member Function Documentation

void RakNet::HTTPConnection::CloseConnection ( ) [private]
static void RakNet::HTTPConnection::DestroyInstance ( HTTPConnection i) [static]
void RakNet::HTTPConnection::Get ( const char *  path)

Get a file from a webserver

Parameters:
paththe path on the remote server you want to GET from. For example "index.html"
static HTTPConnection* RakNet::HTTPConnection::GetInstance ( void  ) [static]
SystemAddress RakNet::HTTPConnection::GetServerAddress ( void  ) const
int RakNet::HTTPConnection::GetState ( void  ) const
bool RakNet::HTTPConnection::HasBadResponse ( int *  code,
RakNet::RakString data 
)
bool RakNet::HTTPConnection::HasRead ( void  ) const
void RakNet::HTTPConnection::Init ( TCPInterface _tcp,
const char *  host,
unsigned short  port = 80 
)
Precondition:
tcp should already be started
bool RakNet::HTTPConnection::IsBusy ( void  ) const
HTTPConnection& RakNet::HTTPConnection::operator= ( const HTTPConnection rhs) [inline]

Definition at line 93 of file HTTPConnection.h.

{(void) rhs; return *this;}
void RakNet::HTTPConnection::Post ( const char *  path,
const char *  data,
const char *  _contentType = "application/x-www-form-urlencoded" 
)

Submit data to the HTTP server HTTP only allows one request at a time per connection

Precondition:
IsBusy()==false
Parameters:
paththe path on the remote server you want to POST to. For example "index.html"
dataA NULL terminated string to submit to the server
contentType"Content-Type:" passed to post.
void RakNet::HTTPConnection::ProcessTCPPacket ( Packet packet)

Process an HTTP data packet returned from TCPInterface Returns true when we have gotten all the data from the HTTP server. If this returns true then it's safe to Post() another request Deallocate the packet as usual via TCPInterface

Parameters:
packetNULL or a packet associated with our host and port
RakNet::RakString RakNet::HTTPConnection::Read ( void  )

Get one result from the server

Precondition:
HasResult must return true
void RakNet::HTTPConnection::Update ( void  )

Member Data Documentation

Definition at line 138 of file HTTPConnection.h.

Definition at line 131 of file HTTPConnection.h.

Definition at line 136 of file HTTPConnection.h.

Definition at line 149 of file HTTPConnection.h.

Definition at line 130 of file HTTPConnection.h.

unsigned short RakNet::HTTPConnection::port [private]

Definition at line 137 of file HTTPConnection.h.

Definition at line 150 of file HTTPConnection.h.

Definition at line 134 of file HTTPConnection.h.

Definition at line 135 of file HTTPConnection.h.


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

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net