#include <Net.h>
Public Member Functions | |
Net (char *myIP, char *opponentIP, uint16 port) | |
~Net () | |
void | SendData (char *msg) |
Static Public Member Functions | |
static s3eInetAddress * | SetUpAddress (char *ip, uint16 port) |
static void | Bind () |
static std::string | RecieveData () |
static char * | GetMyIP () |
static int32 | ConnectCallback (s3eSocket *socket, void *sys, void *data) |
static void | IncomingConnection (s3eSocket *newSocket, s3eInetAddress *address) |
static int32 | AcceptCallback (s3eSocket *sock, void *sysData, void *userData) |
static void | Listen () |
static void | Connect (char *IP, uint16 port) |
Static Protected Attributes | |
static char * | m_myIp |
My ip. | |
static char * | m_opponentIp |
Opponent's ip. | |
static uint16 | m_port |
My port. | |
static s3eSocket * | m_socket |
My websocket. | |
static bool | m_SocketIsConnected |
Has socket connected yet? | |
static s3eSocket * | m_AcceptedSocket |
Check if socket is accepted. | |
static bool | m_Listening |
Is socket listening for messages? |
Net class.
Net which uses Marmalade's websockets to send and receive packets.
Net::Net | ( | char * | myIP, | |
char * | opponentIP, | |||
uint16 | port | |||
) |
Constructor.
Create a new net object, setup ips, and bind ports.
[in] | myIP | My ip address. |
[in] | opponentIP | Opponent's ip address. |
[in] | port | The port. |
Net::~Net | ( | ) | [inline] |
Destructor.
Destroy the net object and release all associated memory.
int32 Net::AcceptCallback | ( | s3eSocket * | sock, | |
void * | sysData, | |||
void * | userData | |||
) | [static] |
Accept callback.
Marmalade method. Accept a socket connection.
[in] | sock | The socket to connect. |
[in] | sysData | NULL. |
[in] | userData | NULL. |
void Net::Bind | ( | ) | [static] |
Bind.
Bind the ports.
void Net::Connect | ( | char * | IP, | |
uint16 | port | |||
) | [static] |
Connect.
Connect to the opponent.
[in] | IP | The opponent's ip address. |
[in] | port | The opponent's port. |
int32 Net::ConnectCallback | ( | s3eSocket * | socket, | |
void * | sys, | |||
void * | data | |||
) | [static] |
Connect callback.
Marmalade method. Checks if socket has been connected.
[in] | socket | Socket to be checked. |
[in] | sys | NULL. |
[in] | data | NULL. |
char * Net::GetMyIP | ( | ) | [static] |
Get my ip address.
Returns the player's ip address.
void Net::IncomingConnection | ( | s3eSocket * | newSocket, | |
s3eInetAddress * | address | |||
) | [static] |
Incoming connection.
Marmalade method. Checks for new incoming connections.
[in] | newSocket | New websocket. |
[in] | address | New internet address. |
void Net::Listen | ( | ) | [static] |
Listen for messages.
Listens for messages from the other player.
std::string Net::RecieveData | ( | ) | [static] |
Receive data.
Listens fot data from the other player.
void Net::SendData | ( | char * | msg | ) |
Send data.
Send a packet to the opponent.
[in] | msg | The message to be sent. |
s3eInetAddress * Net::SetUpAddress | ( | char * | ip, | |
uint16 | port | |||
) | [static] |
Set up address.
Create a new Marmalade Internet Address object.
[in] | ip | My ip address. |
[in] | port | The port. |