1
0
forked from 0ad/0ad
0ad/source/ps/Network/SessionManager.h
olsner 7bcc12373b - Created JSMap
- Changed player colour JS interface: setColour(...) instead of a colour
property
- Introduced a network log and replaced most network LOG() calls with
NET_LOG()
- Moved to a slot-based system for Pre-Game and extended a lot of the JS
APIs to networking stuff
- A bit of cleanup in the low-level network code (Unix parts)
- Clients now keep track of all other connected clients on the server
(And exposes this info to JS)
- Split out GameAttributes to its own file
- Removed unused class AttributeMap
- Changed CJSObject to use T* pointers in JS_SetPrivate (needed to make
ToScript work with multiple inheritance)

This was SVN commit r1929.
2005-02-21 17:13:31 +00:00

56 lines
1.3 KiB
C++
Executable File

#ifndef _Network_SessionManager_H
#define _Network_SessionManager_H
#include <ThreadUtil.h>
class CNetSession;
/*
NAME: CSessionManager
The central nexus of network message handling. Contains the entry point
called from the main thread.
CNetSession's are registered and when the Poll method finds that the session
has a pending message, the session object's HandleMessage method is called
to handle it. Any unhandled messages (HandleMessage returns false) are
logged to the system log.
*/
class CSessionManager: public Singleton<CSessionManager>
{
typedef std::map <CNetSession *, CNetSession *> SessionMap;
SessionMap m_Sessions;
SessionMap m_AddQueue;
SessionMap m_RemoveQueue;
CMutex m_Mutex;
public:
/*
Poll all registered sessions and pass all messages to their
message handlers.
THREADS: Call from Main Thread only
*/
void Poll();
/*
Register a network session with the session manager. Future calls to
Poll() will poll this session's socket and pass any messages to
its message handler function.
THREADS: Safe from all threads
*/
void Register(CNetSession *pSession);
/*
Delete the protocol context associated with the specified socket.
THREADS: Safe from all threads
*/
void Deregister(CNetSession *pSession);
};
#define g_SessionManager (CSessionManager::GetSingleton())
#endif