#include <netpeersocket.h>
Inheritance diagram for NetPeerSocket:
Public Member Functions | |
DECLSPEC | NetPeerSocket (const char *name, NetPeerManager *parent, TCPsocket connection=NULL) |
DECLSPEC | NetPeerSocket (const char *name, NetPeerManager *parent, IPaddress ip) |
DECLSPEC | NetPeerSocket (TiXmlElement *el, NetPeerManager *parent) |
virtual const char * | getClassName () |
const char * | getNetName () |
| |
DECLSPEC Uint32 | fastPing () |
DECLSPEC void | requestPing () |
Uint32 | lastPing () const |
int | getListenPort () |
| |
Static Public Member Functions | |
static void | newsocket (void *presult, BasicObject *o, void *xmldata) |
Protected Member Functions | |
virtual DECLSPEC void | handleData (NetBasicData *d) |
virtual DECLSPEC bool | onReceive () |
virtual DECLSPEC void | onConnect () |
virtual DECLSPEC void | onPing () |
Protected Attributes | |
char | chName [PEER_MAX_NAME+1] |
the name of the host machine in the network | |
int | nListenPort |
port on which one can connect to the socket's host |
NetPeerSocket::NetPeerSocket | ( | const char * | name, | |
NetPeerManager * | parent, | |||
TCPsocket | connection = NULL | |||
) |
Constructor. Usually the 3rd param is only used internally in the Netrinjo library.
connection | the SDL TCPsocket to use, or NULL, if no connection is used. |
NetPeerSocket::NetPeerSocket | ( | const char * | name, | |
NetPeerManager * | parent, | |||
IPaddress | ip | |||
) |
Constructor. Can be used to establish a connection to a host.
ip | the host's IP address, that should be connected. |
NetPeerSocket::NetPeerSocket | ( | TiXmlElement * | el, | |
NetPeerManager * | parent | |||
) |
Constructor with XML-data.
el | the XML-data, |
virtual const char* NetPeerSocket::getClassName | ( | ) | [inline, virtual] |
This function should be overriden in every sub-class of BasicObject!
Reimplemented from NetStandardSocket.
Uint32 NetPeerSocket::fastPing | ( | ) |
void NetPeerSocket::requestPing | ( | ) |
Requests a ping from the host and returns immediatelly. When the host responded, the duration of the ping can be asked with lastPing().
In comparison to fastPing() this function is safe, but usually returns a higher result.
Uint32 NetPeerSocket::lastPing | ( | ) | const [inline] |
void NetPeerSocket::handleData | ( | NetBasicData * | d | ) | [protected, virtual] |
Handles incomming data. This needs not to be used by the app. It is used internally in the Netrinjo engine.
d | the data, that arrived |
bool NetPeerSocket::onReceive | ( | ) | [protected, virtual] |
Calls the callback function, as set by setReceiveCallback(). The 3rd param of the callback-function is used as a pointer to a boolean value. If this is set false, the socket will close.
Reimplemented from NetStandardSocket.
void NetPeerSocket::onConnect | ( | ) | [protected, virtual] |
Called, after a connection has been established successfully. If you want to overwrite this method, do not forget to call the parent class's onConnect();
Reimplemented from NetStandardSocket.
virtual DECLSPEC void NetPeerSocket::onPing | ( | ) | [inline, protected, virtual] |
Called when a ping answer arrived, so tPing has just been refreshed.