RakNet
4.0
|
Use HTTPConnection2 to communicate with a web server. More...
#include <HTTPConnection2.h>
Public Member Functions | |
bool | TransmitRequest (const char *stringToTransmit, const char *host, unsigned short port=80, bool useSSL=false, int ipVersion=4, SystemAddress useAddress=UNASSIGNED_SYSTEM_ADDRESS) |
Connect to, then transmit a request to a TCP based server. | |
bool | GetResponse (RakString &stringTransmitted, RakString &hostTransmitted, RakString &responseReceived, SystemAddress &hostReceived, int &contentOffset) |
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 | 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) |
![]() | |
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, RakNet::TimeMS time, int isSend) |
virtual void | OnAck (unsigned int messageNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time) |
virtual void | OnPushBackPacket (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) |
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
bool RakNet::HTTPConnection2::GetResponse | ( | RakString & | stringTransmitted, |
RakString & | hostTransmitted, | ||
RakString & | responseReceived, | ||
SystemAddress & | hostReceived, | ||
int & | contentOffset | ||
) |
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()
[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. |
|
virtual |
Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system
[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 RakNet::PluginInterface2.
|
virtual |
Called when a connection attempt fails
[in] | packet | Packet to be returned to the user |
[in] | failedConnectionReason | Why the connection failed |
Reimplemented from RakNet::PluginInterface2.
|
virtual |
Called when we got a new connection
[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 RakNet::PluginInterface2.
|
virtual |
OnReceive is called for every packet.
[in] | packet | the packet that is being returned to the user |
Reimplemented from RakNet::PluginInterface2.
bool RakNet::HTTPConnection2::TransmitRequest | ( | const char * | stringToTransmit, |
const char * | host, | ||
unsigned short | port = 80 , |
||
bool | useSSL = false , |
||
int | ipVersion = 4 , |
||
SystemAddress | useAddress = UNASSIGNED_SYSTEM_ADDRESS |
||
) |
Connect to, then transmit a request to a TCP based server.
[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 RakNetDefines.h or RakNetDefinesOverrides.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 |