cyphesis/server/CommClient.h
Al Riddoch 1a59d10ddd 2006-12-22 Al Riddoch <alriddoch@zepler.org>
* server/CommClient.h, server/CommListener.h, server/CommLocalClient.h,
	  server/CommMDNSPublisher.h, server/CommMaster.h,
	  server/CommMetaClient.h, server/CommPSQLSocket.h,
	  server/CommPeer.h, server/CommPeerListener.h,
	  server/CommRemoteClient.h, server/CommServer.h,
	  server/CommSlaveClient.h, server/CommSlaveListener.h,
	  server/CommSocket.cpp, server/CommSocket.h,
	  server/CommUnixListener.h: Add a documentation group for socket
	  classes.

	* rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
	  rulesets/Py_Location.h, rulesets/Py_Map.h, rulesets/Py_Mind.h,
	  rulesets/Py_Object.h, rulesets/Py_Operation.h,
	  rulesets/Py_Oplist.h, rulesets/Py_Optime.h, rulesets/Py_Point3D.h,
	  rulesets/Py_Property.h, rulesets/Py_Quaternion.h,
	  rulesets/Py_RootEntity.h, rulesets/Py_Task.h, rulesets/Py_Thing.h,
	  rulesets/Py_Vector3D.h, rulesets/Py_World.h, rulesets/Py_WorldTime.h,
	  rulesets/Python_API.cpp: Add documentation group for Python wrapper
	  types.

	* rulesets/Container.h, rulesets/PythonScript.cpp,
	  server/ScriptFactory.h, server/ScriptFactory.cpp:
	  Add more inline documentation comments.
2006-12-22 02:14:44 +00:00

98 lines
3.1 KiB
C++

// Cyphesis Online RPG Server and AI Engine
// Copyright (C) 2000-2004 Alistair Riddoch
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
// $Id: CommClient.h,v 1.54 2006-12-22 02:14:44 alriddoch Exp $
#ifndef SERVER_COMM_CLIENT_H
#define SERVER_COMM_CLIENT_H
#include "CommSocket.h"
#include "Idle.h"
#include <Atlas/Objects/Decoder.h>
#include <Atlas/Objects/ObjectsFwd.h>
#include <skstream/skstream.h>
#include <deque>
namespace Atlas {
class Codec;
namespace Objects {
class ObjectsEncoder;
}
class Negotiate;
}
class BaseEntity;
/// \brief Base class for Atlas clients connected to the server.
///
/// Used by subclasses to handle remote TCP clients and local UNIX clients.
/// \ingroup ServerSockets
class CommClient : public Atlas::Objects::ObjectsDecoder, public CommSocket, public Idle {
public:
/// \brief STL deque of pointers to operation objects.
typedef std::deque<Atlas::Objects::Operation::RootOperation> DispatchQueue;
protected:
/// \brief C++ iostream compatible socket object handling the socket IO.
tcp_socket_stream m_clientIos;
/// \brief Queue of operations that have been decoded by not dispatched.
DispatchQueue m_opQueue;
/// \brief Atlas codec that handles encoding and decoding traffic.
Atlas::Codec * m_codec;
/// \brief high level encoder passes data to the codec for transmission.
Atlas::Objects::ObjectsEncoder * m_encoder;
/// \brief Atlas negotiator for handling codec negotiation.
Atlas::Negotiate * m_negotiate;
/// \brief Server side object for handling connection level operations.
BaseEntity & m_connection;
/// \brief Time connection was opened
time_t m_connectTime;
/// \brief Handle socket data related to codec negotiation.
int negotiate();
/// \brief Add an operation to the queue.
template <class OpType>
void queue(const OpType &);
bool timeout() { return m_clientIos.timeout(); }
int operation(const Atlas::Objects::Operation::RootOperation &);
virtual void objectArrived(const Atlas::Objects::Root & obj);
virtual void idle(time_t t);
public:
CommClient(CommServer &, int fd, BaseEntity &);
CommClient(CommServer &, BaseEntity &);
virtual ~CommClient();
void disconnect() { m_clientIos.shutdown(); }
void setup();
int send(const Atlas::Objects::Operation::RootOperation &);
int getFd() const;
bool isOpen() const;
bool eof();
int read();
void dispatch();
};
#endif // SERVER_COMM_CLIENT_H