SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
SLNet::HTTPConnection Class Reference

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

`#include <slikenet/HTTPConnection.h>`

## 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

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

## Public Attributes

DataStructures::Queue < OutgoingCommand > | outgoingCommand
OutgoingCommand | currentProcessingCommand

## Detailed Description

Use HTTPConnection to communicate with a web server.

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.

Deprecated:
  , use HTTPConnection2

Definition at line 47 of file HTTPConnection.h.

## Class Documentation

struct SLNet::HTTPConnection::OutgoingCommand

Definition at line 126 of file HTTPConnection.h.

Class Members
RakString | contentType |
RakString | data |
bool | isPost |
RakString | remotePath |

## Member Enumeration Documentation

enum SLNet::HTTPConnection::ResponseCodes

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 95 of file HTTPConnection.h.

## Constructor & Destructor Documentation

SLNet::HTTPConnection::HTTPConnection | ( |  | ) |

Returns a HTTP object associated with this tcp connection.

virtual SLNet::HTTPConnection::~HTTPConnection | ( |  | ) |

virtual

## Member Function Documentation

void SLNet::HTTPConnection::Get | ( | const char * | path | ) |

Get a file from a webserver

Parameters

  path | the path on the remote server you want to GET from. For example "index.html"

SystemAddress SLNet::HTTPConnection::GetServerAddress | ( | void |  | ) | const

Returns the address of the server we are connected to.

int SLNet::HTTPConnection::GetState | ( | void |  | ) | const

bool SLNet::HTTPConnection::HasBadResponse | ( | int * | code,
|  | SLNet::RakString * | data
| ) |  |

Queued events of failed exchanges with the HTTP server.

bool SLNet::HTTPConnection::HasRead | ( | void |  | ) | const

Is there a Read result ready?

void SLNet::HTTPConnection::Init | ( | TCPInterface * | _tcp,
|  | const char * | host,
|  | unsigned short | port = `80`
| ) |  |

Precondition
  tcp should already be started

bool SLNet::HTTPConnection::IsBusy | ( | void |  | ) | const

Returns false if the connection is not doing anything else.

HTTPConnection& SLNet::HTTPConnection::operator= | ( | const HTTPConnection & | rhs | ) |

inline

Definition at line 97 of file HTTPConnection.h.

void SLNet::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

  path | the path on the remote server you want to POST to. For example "index.html"
  data | A NULL terminated string to submit to the server
  contentType | "Content-Type:" passed to post.

void SLNet::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

  packet | NULL or a packet associated with our host and port

SLNet::RakString SLNet::HTTPConnection::Read | ( | void |  | ) |

Get one result from the server

Precondition
  HasResult must return true

void SLNet::HTTPConnection::Update | ( | void |  | ) |

Call periodically to do time-based updates.

## Member Data Documentation

OutgoingCommand SLNet::HTTPConnection::currentProcessingCommand

Definition at line 135 of file HTTPConnection.h.

DataStructures::Queue<OutgoingCommand> SLNet::HTTPConnection::outgoingCommand

Definition at line 134 of file HTTPConnection.h.

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

- Source/include/slikenet/HTTPConnection.h