#include <clientframework.h>
Inheritance diagram for ClientFramework:
Public Types | |
enum | ClientState { NOT_STARTED = 1000, HANDSHAKING_INIT = 3001, HANDSHAKING_ABORTED_BY_SERVER = 3002, HANDSHAKING_ABORTED_BY_CLIENT = 3003, CONNECTED = 4000, DISCONNECTED = 5000 } |
Public Member Functions | |
ClientFramework (int local_port) | |
~ClientFramework () | |
void | initServerConnection (const std::string &_server_host, int _server_port) |
This method starts the listning and receiving sockets of the framework. It also starts the handshaking session between the client framwork and the server. | |
void | terminateServerConnection () |
This method will stop both the sender and the receiver if they are started, and clean out the queues. | |
virtual void | unregisterData (ClientData *data) |
ClientData * | getDataObject (unsigned int objid) |
This method will return a pointer to a ClientData object (or null if the object does not exist on the client). | |
void | registerPointer (unsigned int receiver, unsigned int missing, ClientData **ptrptr) |
This method will add to the pointer-pointer-table-thingy a missing pointer. | |
bool | unregisterPointer (unsigned int receiver, unsigned int objid, ClientData **ptrptr) |
This method will deletea pointer from the pointer-pointer-table. | |
void | registerConstructor (unsigned int class_id, ClientData *(*func)(ClientFramework *, ClientPacket *)) |
This method will register a constructor-method with a class-id. | |
void | registerPlugin (Plugin< ClientPacket > *plugin) |
Will register a plugin in the framework, plugins are used to "unpack" packets created with the same plugin on the server side (example: compression). | |
void | keepAlive (unsigned int sleepmillis=0) |
This will handle any incomming packets, along with other keep-alive-stuff. | |
virtual bool | isPacketReadyForDelivery (ClientPacket *packet) |
virtual ClientPacket * | deliverPacket (ClientPacket *p) |
unsigned int | getNextUnreliablePacketSeqNumber (ClientPacket *packet) |
This will return the next sequence number for the outgoing packet, and increment it also. | |
virtual void | addPendingAck (ClientPacket *packet, bool haslock) |
Called when we want to insert a pending ack into the pendingackist. | |
virtual void | sentReliablePacket (ClientPacket *packet) |
void | enqueuePacket (ClientPacket *p, bool sendnow=false) |
This method enqueues a packet. | |
ClientState | getState () const |
This method will return the current state of the client;. | |
const std::map< unsigned int, ClientData * > & | getClientDataObjects () const |
This method will return a complete list of ClientData objects registered in the framework. | |
void | printPointerPointerMapDebug () const |
Just a debug method. | |
virtual void | retransmitPacket (FrameworkPacket *packet) |
Will be called by the pendingacklist when ever we want to retransmit a packet. | |
unsigned long | bytesReceived () const |
unsigned long | packetsReceived () const |
unsigned long | packetsDelivered () const |
unsigned long | getSkippedUnreliablePackets () const |
unsigned long | getSkippedReliablePackets () const |
unsigned long | bytesSent () const |
unsigned long | packetsSent () const |
unsigned long | inQueueSize () const |
unsigned long | outQueueSize () const |
unsigned long | getPendingAckCount () const |
unsigned int | bufferedPackets () const |
Returns total count of packets buffered due to deliver-in-order. | |
Protected Member Functions | |
virtual void | writeHandshakeInitMessage (ClientPacket *fp)=0 |
virtual void | onHandshakingDiscontinue (ClientPacket *fp)=0 |
If the server will not let you connect, you can read what ever was written to you. | |
virtual bool | onHandshakeDescription (ClientPacket *fp, ClientPacket *reply)=0 |
virtual void | onDisconnect ()=0 |
virtual void | onConnect ()=0 |
virtual void | addPluginSequenceNumber (ClientPacket *packet) |
This method should add a sequence number to the pluginpacket if it does not already have one. | |
Friends | |
class | ClientData |
testclient/testclientframework.cpp, testclient/testclientframework.h, testclient/testclientsnakebite.cpp, and testclient/testclientsnakebite.h.
Definition at line 50 of file clientframework.h.
|
Definition at line 56 of file clientframework.h. |
|
This method will deliver the packet and return any buffered packets, waiting for this packet. Implements Framework< ClientPacket, ipmessage >. Definition at line 502 of file clientframework.cpp. References FrameworkPacket::getType(), FrameworkSeqNoList< PacketType, SocketType >::incrementNextIngoingSeqNo(), Framework< ClientPacket, ipmessage >::inqueue, Queue< PacketType >::insert(), and FrameworkPacket::isReliable(). |
|
This method tests if a packet is in order, and if not buffer the packet for later delivery. Implements Framework< ClientPacket, ipmessage >. Definition at line 456 of file clientframework.cpp. References FrameworkSeqNoList< PacketType, SocketType >::bufferPacket(), CONNECTED, FrameworkSeqNoList< PacketType, SocketType >::getNextIngoingSeqNo(), FrameworkPacket::getSequenceNumber(), HANDSHAKING_INIT, FrameworkSeqNoList< PacketType, SocketType >::incrementNextIngoingSeqNo(), FrameworkSeqNoList< PacketType, SocketType >::isFuture(), FrameworkSeqNoList< PacketType, SocketType >::isNext(), and FrameworkPacket::isReliable(). |
|
Will be called during "keepAlive(...)" if the client has successfully connected to the server. Referenced by keepAlive(). |
|
Will be called during "keepAlive(...)" if the client has lost the connection to the server. Referenced by keepAlive(). |
|
If the server will let you connect, then here is the packet from the server, and you can reply in the other packet. |
|
This method will be called by the sender when ever it successfully sends a reliable packet to the socket, we will register the time. Implements Framework< ClientPacket, ipmessage >. Definition at line 533 of file clientframework.cpp. |
|
This method is called just before a connection attempt, you can write any gamespecific data in the packet for the server to read. Referenced by initServerConnection(). |