Public Member Functions | Static Public Member Functions | Static Protected Attributes

Net Class Reference

Net class. More...

#include <Net.h>

List of all members.

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?

Detailed Description

Net class.

Net which uses Marmalade's websockets to send and receive packets.


Constructor & Destructor Documentation

Net::Net ( char *  myIP,
char *  opponentIP,
uint16  port 
)

Constructor.

Create a new net object, setup ips, and bind ports.

Parameters:
[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.


Member Function Documentation

int32 Net::AcceptCallback ( s3eSocket *  sock,
void *  sysData,
void *  userData 
) [static]

Accept callback.

Marmalade method. Accept a socket connection.

Parameters:
[in] sock The socket to connect.
[in] sysData NULL.
[in] userData NULL.
Returns:
int32 always returns 0.
void Net::Bind (  )  [static]

Bind.

Bind the ports.

void Net::Connect ( char *  IP,
uint16  port 
) [static]

Connect.

Connect to the opponent.

Parameters:
[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.

Parameters:
[in] socket Socket to be checked.
[in] sys NULL.
[in] data NULL.
Returns:
int32 always returns 0.
char * Net::GetMyIP (  )  [static]

Get my ip address.

Returns the player's ip address.

Returns:
char* ip address.
void Net::IncomingConnection ( s3eSocket *  newSocket,
s3eInetAddress *  address 
) [static]

Incoming connection.

Marmalade method. Checks for new incoming connections.

Parameters:
[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.

Returns:
std::string data as a string (converted from char*).
void Net::SendData ( char *  msg  ) 

Send data.

Send a packet to the opponent.

Parameters:
[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.

Parameters:
[in] ip My ip address.
[in] port The port.
Returns:
s3eInetAddress* a new address object.

The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations