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

ServerFramework Class Reference
[GanefServer]

This class is the framework on the server. it contains a list of connected clients, a sender, a reciever, pending-ack-list and all the data used to represent the gameworld. More...

#include <serverframework.h>

Inheritance diagram for ServerFramework:

Framework< ServerPacket, ipmsgserver > List of all members.

Public Member Functions

 ServerFramework (int port)
 ~ServerFramework ()
ServerDatagetDataObject (unsigned int objid)
 Return the object with the given id, or NULL if none exists.
void registerPreSendingChain (const std::string &chainname, const std::vector< Plugin< ServerPacket > * > &stations)
 Register a chain of plugins used to process packets before they are added in the outqueue.
void setPreSendingChain (const std::string &chainname)
 Set the current chain of plugins.
void setDefaultPreSendingChain ()
 Set the current chain of plugins to the default (no plugins used, strait to the outqueue).
void purgeCurrentPreSendingChain ()
 This method will "purge" the active presending chain.
void setConnectionTimeout (unsigned int ct)
 Change the number of milliseconds that the server/clients will use to determine if a silent disconnect has occured.
virtual void keepAlive (unsigned int sleepmillis=0)
 This will handle any incomming packets, along with other keep-alive-stuff.
virtual bool isPacketReadyForDelivery (ServerPacket *packet)
virtual ServerPacketdeliverPacket (ServerPacket *packet)
virtual void addPendingAck (ServerPacket *packet, bool haslock)
 Called when we want to insert a pending ack into the pendingacklist.
virtual unsigned int bufferedPackets () const
 Returns total count of packets buffered on all clients, due to deliver-in-order.
virtual void sentReliablePacket (ServerPacket *packet)
std::map< unsigned int, Client * > & getAllClients ()
 Get all the well registered clients.
const std::map< unsigned int,
ServerData * > & 
getServerDataObjects () const
 Get all server data objects.
void enqueuePacket (ServerPacket *packet, const std::map< unsigned int, Client * > &clientlist)
 This method will copy the packet and enqueue a copy for each client.
void enqueuePacket (ServerPacket *packet, Client *client)
 This method will just enqueue the packet for this single client.
void start ()

Protected Member Functions

virtual bool onInitialHandshake (ServerPacket *handshake, ServerPacket *reply)=0
virtual void onClientConnected (Client *client)=0
 This method will be invoked when a new client has passed the handshaking-phase.
virtual void onClientDisconnected (Client *client)=0
 This method will be invoked when a client has timed out.
virtual ClientcreateClient (const ipaddress &addr, int port)=0
 This method should return some dirivative of the Client-class.
virtual void addPluginSequenceNumber (ServerPacket *packet)
 This method should add a sequence number to the pluginpacket if it does not already have one.

Friends

class ServerData

Detailed Description

This class is the framework on the server. it contains a list of connected clients, a sender, a reciever, pending-ack-list and all the data used to represent the gameworld.

Author:
Lars Langer and Emanuel Greisen
Examples:

testserver/testserverframework.cpp, testserver/testserverframework.h, testserver/testserversnakebite.cpp, and testserver/testserversnakebite.h.

Definition at line 65 of file serverframework.h.


Member Function Documentation

ServerPacket * ServerFramework::deliverPacket ServerPacket packet  )  [virtual]
 

This method delivers all packets, and returns any buffered packets waiting for the packet.

Implements Framework< ServerPacket, ipmsgserver >.

Definition at line 386 of file serverframework.cpp.

References ServerPacket::client, Framework< ServerPacket, ipmsgserver >::currentTimeMillis(), FrameworkPacket::getType(), Client::incrementNextIngoingSeqNo(), Framework< ServerPacket, ipmsgserver >::inqueue, Queue< PacketType >::insert(), FrameworkPacket::isReliable(), and Client::registerLastPacketReceivedTime().

bool ServerFramework::isPacketReadyForDelivery ServerPacket packet  )  [virtual]
 

This method will test if a packet is in order, and if not buffer the packet for later delivery.

Implements Framework< ServerPacket, ipmsgserver >.

Definition at line 413 of file serverframework.cpp.

References ServerPacket::client, createClient(), FrameworkPacket::PeerStruct::host, FrameworkPacket::isHandshakeInitPacket(), Client::isPacketReadyForDelivery(), FrameworkPacket::peer, and FrameworkPacket::PeerStruct::port.

virtual bool ServerFramework::onInitialHandshake ServerPacket handshake,
ServerPacket reply
[protected, pure virtual]
 

This method should write it's reply in the reply-packet, and return true or false depending on wether it want's us to continue the handshaking.

void ServerFramework::sentReliablePacket ServerPacket packet  )  [virtual]
 

This method will be called by the sender when ever it successfully sends a reliable packet to the socket, we will look up the client and register this on him/her.

Implements Framework< ServerPacket, ipmsgserver >.

Definition at line 452 of file serverframework.cpp.


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