Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

ClientFramework Class Reference
[GanefClient]

This class is the framework on the client. With sender, reciever, pending-ack-list and all client data. This is the class you must inherit from on the client side of your game. More...

#include <clientframework.h>

Inheritance diagram for ClientFramework:

Framework< ClientPacket, ipmessage > List of all members.

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

Detailed Description

This class is the framework on the client. With sender, reciever, pending-ack-list and all client data. This is the class you must inherit from on the client side of your game.

Author:
Lars Langer and Emanuel Greisen
Examples:

testclient/testclientframework.cpp, testclient/testclientframework.h, testclient/testclientsnakebite.cpp, and testclient/testclientsnakebite.h.

Definition at line 50 of file clientframework.h.


Member Enumeration Documentation

enum ClientFramework::ClientState
 

Enumerator:
NOT_STARTED  Framework initialized, but not started.
HANDSHAKING_INIT  Handshaking initilized.
HANDSHAKING_ABORTED_BY_SERVER  Handshaking was aborted by the server.
HANDSHAKING_ABORTED_BY_CLIENT  Handshaking was aborted by the server.
CONNECTED  Client and server in agreement - client connected.
DISCONNECTED  Now we are disconnected (but we were connected before).

Definition at line 56 of file clientframework.h.


Member Function Documentation

ClientPacket * ClientFramework::deliverPacket ClientPacket p  )  [virtual]
 

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

bool ClientFramework::isPacketReadyForDelivery ClientPacket packet  )  [virtual]
 

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

virtual void ClientFramework::onConnect  )  [protected, pure virtual]
 

Will be called during "keepAlive(...)" if the client has successfully connected to the server.

Referenced by keepAlive().

virtual void ClientFramework::onDisconnect  )  [protected, pure virtual]
 

Will be called during "keepAlive(...)" if the client has lost the connection to the server.

Referenced by keepAlive().

virtual bool ClientFramework::onHandshakeDescription ClientPacket fp,
ClientPacket reply
[protected, pure virtual]
 

If the server will let you connect, then here is the packet from the server, and you can reply in the other packet.

void ClientFramework::sentReliablePacket ClientPacket packet  )  [virtual]
 

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.

virtual void ClientFramework::writeHandshakeInitMessage ClientPacket fp  )  [protected, pure virtual]
 

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


The documentation for this class was generated from the following files:
Generated on Mon Feb 6 12:24:51 2006 for Ganef by  doxygen 1.4.4