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 Member Functions | Protected Member Functions | Protected Attributes | List of all members
SLNet::HTTPConnection2 Class Reference

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

`#include <slikenet/HTTPConnection2.h>`

Inheritance diagram for SLNet::HTTPConnection2:

## Classes

struct | Request

## Public Member Functions

| HTTPConnection2 ()
virtual | ~HTTPConnection2 ()
bool | TransmitRequest (const char *stringToTransmit, const char *host, unsigned short port=80, bool useSSL=false, int ipVersion=4, SystemAddress useAddress=UNASSIGNED_SYSTEM_ADDRESS, void *userData=0)
| Connect to, then transmit a request to a TCP based server.
bool | GetResponse (RakString &stringTransmitted, RakString &hostTransmitted, RakString &responseReceived, SystemAddress &hostReceived, ptrdiff_t &contentOffset, void **userData)

Check for and return a response from a prior call to TransmitRequest() As TCP is stream based, you may get a webserver reply over several calls to TCPInterface::Receive() HTTPConnection2 will store Packet::data and return the response to you either when the connection to the webserver is lost, or enough data has been received() This will only potentially return true after a call to ProcessTCPPacket() or OnLostConnection()

bool | GetResponse (RakString &stringTransmitted, RakString &hostTransmitted, RakString &responseReceived, SystemAddress &hostReceived, ptrdiff_t &contentOffset)
bool | IsBusy (void) const
| Return if any requests are pending.
bool | HasResponse (void) const
| Return if any requests are waiting to be read by the user.
virtual PluginReceiveResult | OnReceive (Packet *packet)
virtual void | OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
virtual void | OnNewConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
virtual void | OnFailedConnectionAttempt (Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason)
Public Member Functions inherited from SLNet::PluginInterface2
| PluginInterface2 ()
virtual | ~PluginInterface2 ()
virtual void | OnAttach (void)
| Called when the interface is attached.
virtual void | OnDetach (void)
| Called when the interface is detached.
virtual void | Update (void)
| Update is called every time a packet is checked for .
virtual void | OnRakPeerStartup (void)
| Called when RakPeer is initialized.
virtual void | OnRakPeerShutdown (void)
| Called when RakPeer is shutdown.
virtual bool | UsesReliabilityLayer (void) const
virtual void | OnDirectSocketSend (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
virtual void | OnDirectSocketReceive (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
virtual void | OnReliabilityLayerNotification (const char *errorMessage, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress, bool isError)
virtual void | OnInternalPacket (InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time, int isSend)
virtual void | OnAck (unsigned int messageNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time)
virtual void | OnPushBackPacket (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
RakPeerInterface * | GetRakPeerInterface (void) const
RakNetGUID | GetMyGUIDUnified (void) const
void | SetRakPeerInterface (RakPeerInterface *ptr)
void | SetTCPInterface (TCPInterface *ptr)

## Protected Member Functions

bool | IsConnected (SystemAddress sa)
void | SendRequest (Request *request)
void | RemovePendingRequest (SystemAddress sa)
void | SendNextPendingRequest (void)
void | SendPendingRequestToConnectedSystem (SystemAddress sa)
Protected Member Functions inherited from SLNet::PluginInterface2
void | SendUnified (const SLNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
void | SendUnified (const char *data, const int length, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
bool | SendListUnified (const char **data, const int *lengths, const int numParameters, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
Packet * | AllocatePacketUnified (unsigned dataSize)
void | PushBackPacketUnified (Packet *packet, bool pushAtHead)
void | DeallocPacketUnified (Packet *packet)

## Protected Attributes

DataStructures::Queue< Request * > | pendingRequests
DataStructures::List< Request * > | sentRequests
DataStructures::List< Request * > | completedRequests
SimpleMutex | pendingRequestsMutex
SimpleMutex | sentRequestsMutex
SimpleMutex | completedRequestsMutex
Protected Attributes inherited from SLNet::PluginInterface2
RakPeerInterface * | rakPeerInterface
TCPInterface * | tcpInterface

## Detailed Description

Use HTTPConnection2 to communicate with a web server.

Start an instance of TCPInterface via the Start() command. This class will handle connecting to transmit a request

Definition at line 44 of file HTTPConnection2.h.

## Class Documentation

struct SLNet::HTTPConnection2::Request

Definition at line 85 of file HTTPConnection2.h.

Class Members
size_t | bytesReadForThisChunk |
bool | chunked |
int | contentLength |
ptrdiff_t | contentOffset |
RakString | host |
SystemAddress | hostCompletedAddress |
SystemAddress | hostEstimatedAddress |
int | ipVersion |
unsigned short | port |
RakString | stringReceived |
RakString | stringToTransmit |
size_t | thisChunkSize |
void * | userData |
bool | useSSL |

## Constructor & Destructor Documentation

SLNet::HTTPConnection2::HTTPConnection2 | ( |  | ) |

virtual SLNet::HTTPConnection2::~HTTPConnection2 | ( |  | ) |

virtual

## Member Function Documentation

bool SLNet::HTTPConnection2::GetResponse | ( | RakString & | stringTransmitted,
|  | RakString & | hostTransmitted,
|  | RakString & | responseReceived,
|  | SystemAddress & | hostReceived,
|  | ptrdiff_t & | contentOffset,
|  | void ** | userData
| ) |  |

Check for and return a response from a prior call to TransmitRequest() As TCP is stream based, you may get a webserver reply over several calls to TCPInterface::Receive() HTTPConnection2 will store Packet::data and return the response to you either when the connection to the webserver is lost, or enough data has been received() This will only potentially return true after a call to ProcessTCPPacket() or OnLostConnection()

Parameters

  [out] | stringTransmitted | The original string transmitted
  [out] | hostTransmitted | The parameter of the same name passed to TransmitRequest()
  [out] | responseReceived | The response, if any
  [out] | hostReceived | The SystemAddress from ProcessTCPPacket() or OnLostConnection()
  [out] | contentOffset | The offset from the start of responseReceived to the data body. Equivalent to searching for in responseReceived.
  [out] | userData | Whatever you passed to TransmitRequest

Returns
  true if there was a response. false if not.

bool SLNet::HTTPConnection2::GetResponse | ( | RakString & | stringTransmitted,
|  | RakString & | hostTransmitted,
|  | RakString & | responseReceived,
|  | SystemAddress & | hostReceived,
|  | ptrdiff_t & | contentOffset
| ) |  |

bool SLNet::HTTPConnection2::HasResponse | ( | void |  | ) | const

Return if any requests are waiting to be read by the user.

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

Return if any requests are pending.

bool SLNet::HTTPConnection2::IsConnected | ( | SystemAddress | sa | ) |

protected

virtual void SLNet::HTTPConnection2::OnClosedConnection | ( | const SystemAddress & | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | PI2_LostConnectionReason | lostConnectionReason
| ) |  |

virtual

Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system

Parameters

  [in] | systemAddress | The system whose connection was closed
  [in] | rakNetGuid | The guid of the specified system
  [in] | lostConnectionReason | How the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from SLNet::PluginInterface2.

virtual void SLNet::HTTPConnection2::OnFailedConnectionAttempt | ( | Packet * | packet,
|  | PI2_FailedConnectionAttemptReason | failedConnectionAttemptReason
| ) |  |

virtual

Called when a connection attempt fails

Parameters

  [in] | packet | Packet to be returned to the user
  [in] | failedConnectionReason | Why the connection failed

Reimplemented from SLNet::PluginInterface2.

virtual void SLNet::HTTPConnection2::OnNewConnection | ( | const SystemAddress & | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | bool | isIncoming
| ) |  |

virtual

Called when we got a new connection

Parameters

  [in] | systemAddress | Address of the new connection
  [in] | rakNetGuid | The guid of the specified system
  [in] | isIncoming | If true, this is ID_NEW_INCOMING_CONNECTION, or the equivalent

Reimplemented from SLNet::PluginInterface2.

virtual PluginReceiveResult SLNet::HTTPConnection2::OnReceive | ( | Packet * | packet | ) |

virtual

OnReceive is called for every packet.

Parameters

  [in] | packet | the packet that is being returned to the user

Returns
  True to allow the game and other plugins to get this message, false to absorb it

Reimplemented from SLNet::PluginInterface2.

void SLNet::HTTPConnection2::RemovePendingRequest | ( | SystemAddress | sa | ) |

protected

void SLNet::HTTPConnection2::SendNextPendingRequest | ( | void |  | ) |

protected

void SLNet::HTTPConnection2::SendPendingRequestToConnectedSystem | ( | SystemAddress | sa | ) |

protected

void SLNet::HTTPConnection2::SendRequest | ( | Request * | request | ) |

protected

bool SLNet::HTTPConnection2::TransmitRequest | ( | const char * | stringToTransmit,
|  | const char * | host,
|  | unsigned short | port = `80`,
|  | bool | useSSL = `false`,
|  | int | ipVersion = `4`,
|  | SystemAddress | useAddress = `UNASSIGNED_SYSTEM_ADDRESS`,
|  | void * | userData = `0`
| ) |  |

Connect to, then transmit a request to a TCP based server.

Parameters

  [in] | tcp | An instance of TCPInterface that previously had TCPInterface::Start() called
  [in] | stringToTransmit | What string to transmit. See RakString::FormatForPOST(), RakString::FormatForGET(), RakString::FormatForDELETE()
  [in] | host | The IP address to connect to
  [in] | port | The port to connect to
  [in] | useSSL | If to use SSL to connect. OPEN_SSL_CLIENT_SUPPORT must be defined to 1 in defines.h or defineoverrides.h
  [in] | ipVersion | 4 for IPV4, 6 for IPV6
  [in] | useAddress | Assume we are connected to this address and send to it, rather than do a lookup
  [in] | userData |

Returns
  false if host is not a valid IP address or domain name

## Member Data Documentation

DataStructures::List<Request*> SLNet::HTTPConnection2::completedRequests

protected

Definition at line 119 of file HTTPConnection2.h.

SimpleMutex SLNet::HTTPConnection2::completedRequestsMutex

protected

Definition at line 121 of file HTTPConnection2.h.

DataStructures::Queue<Request*> SLNet::HTTPConnection2::pendingRequests

protected

Definition at line 117 of file HTTPConnection2.h.

SimpleMutex SLNet::HTTPConnection2::pendingRequestsMutex

protected

Definition at line 121 of file HTTPConnection2.h.

DataStructures::List<Request*> SLNet::HTTPConnection2::sentRequests

protected

Definition at line 118 of file HTTPConnection2.h.

SimpleMutex SLNet::HTTPConnection2::sentRequestsMutex

protected

Definition at line 121 of file HTTPConnection2.h.

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

- Source/include/slikenet/HTTPConnection2.h