RakNet  4.0
Public Member Functions | List of all members
RakNet::HTTPConnection2 Class Reference

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

#include <HTTPConnection2.h>

Inheritance diagram for RakNet::HTTPConnection2:
RakNet::PluginInterface2

Public Member Functions

bool TransmitRequest (RakString stringToTransmit, RakString host, unsigned short port=80, 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()
 
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 RakNet::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, 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)
 

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

Member Function Documentation

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()

Parameters
[out]stringTransmittedThe original string transmitted
[out]hostTransmittedThe parameter of the same name passed to TransmitRequest()
[out]responseReceivedThe response, if any
[out]hostReceivedThe SystemAddress from ProcessTCPPacket() or OnLostConnection()
[out]contentOffsetThe offset from the start of responseReceived to the data body. Equivalent to searching for

in responseReceived.
Returns
true if there was a response. false if not.
virtual void RakNet::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]systemAddressThe system whose connection was closed
[in]rakNetGuidThe guid of the specified system
[in]lostConnectionReasonHow the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from RakNet::PluginInterface2.

virtual void RakNet::HTTPConnection2::OnFailedConnectionAttempt ( Packet packet,
PI2_FailedConnectionAttemptReason  failedConnectionAttemptReason 
)
virtual

Called when a connection attempt fails

Parameters
[in]packetPacket to be returned to the user
[in]failedConnectionReasonWhy the connection failed

Reimplemented from RakNet::PluginInterface2.

virtual void RakNet::HTTPConnection2::OnNewConnection ( const SystemAddress systemAddress,
RakNetGUID  rakNetGUID,
bool  isIncoming 
)
virtual

Called when we got a new connection

Parameters
[in]systemAddressAddress of the new connection
[in]rakNetGuidThe guid of the specified system
[in]isIncomingIf true, this is ID_NEW_INCOMING_CONNECTION, or the equivalent

Reimplemented from RakNet::PluginInterface2.

virtual PluginReceiveResult RakNet::HTTPConnection2::OnReceive ( Packet packet)
virtual

OnReceive is called for every packet.

Parameters
[in]packetthe 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 RakNet::PluginInterface2.

bool RakNet::HTTPConnection2::TransmitRequest ( RakString  stringToTransmit,
RakString  host,
unsigned short  port = 80,
int  ipVersion = 4,
SystemAddress  useAddress = UNASSIGNED_SYSTEM_ADDRESS 
)

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

Parameters
[in]tcpAn instance of TCPInterface that previously had TCPInterface::Start() called
[in]stringToTransmitWhat string to transmit. See RakString::FormatForPOST(), RakString::FormatForGET(), RakString::FormatForDELETE()
[in]hostThe IP address to connect to
[in]portThe port to connect to
[in]ipVersion4 for IPV4, 6 for IPV6
[in]useAddressAssume we are connected to this address and send to it, rather than do a lookup
Returns
false if host is not a valid IP address or domain name

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