forked from 0ad/0ad
olsner
7bcc12373b
- 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.
71 lines
1.6 KiB
C++
71 lines
1.6 KiB
C++
/*
|
|
CNetServerSession - the server's representation of a connected client
|
|
|
|
AUTHOR: Simon Brenner <simon.brenner@home.se>
|
|
|
|
DESCRIPTION:
|
|
|
|
*/
|
|
|
|
#ifndef _Network_ServerSession_H
|
|
#define _Network_ServerSession_H
|
|
|
|
#include "Network/Session.h"
|
|
#include "scripting/ScriptableObject.h"
|
|
|
|
class CNetServer;
|
|
class CPlayer;
|
|
class CPlayerSlot;
|
|
|
|
class CNetServerSession: public CNetSession, public CJSObject<CNetServerSession>
|
|
{
|
|
CNetServer *m_pServer;
|
|
CPlayer *m_pPlayer;
|
|
CPlayerSlot *m_pPlayerSlot;
|
|
bool m_IsObserver;
|
|
int m_ID;
|
|
|
|
// JS INTERFACE
|
|
static void ScriptingInit();
|
|
bool JSI_Close(JSContext *cx, uintN argc, jsval *argv);
|
|
|
|
protected:
|
|
friend class CNetServer;
|
|
|
|
inline void SetPlayer(CPlayer *pPlayer)
|
|
{ m_pPlayer=pPlayer; }
|
|
|
|
inline void SetPlayerSlot(CPlayerSlot *pPlayerSlot)
|
|
{ m_pPlayerSlot=pPlayerSlot; }
|
|
|
|
inline void SetID(int id)
|
|
{ m_ID=id; }
|
|
|
|
public:
|
|
CNetServerSession(CNetServer *pServer, CSocketInternal *pInt, MessageHandler *pMsgHandler=HandshakeHandler);
|
|
virtual ~CNetServerSession();
|
|
|
|
inline bool IsObserver()
|
|
{ return m_IsObserver; }
|
|
inline CPlayer *GetPlayer()
|
|
{ return m_pPlayer; }
|
|
inline CPlayerSlot *GetPlayerSlot()
|
|
{ return m_pPlayerSlot; }
|
|
inline int GetID()
|
|
{ return m_ID; }
|
|
|
|
// Called by server when starting the game, after sending NMT_StartGame to
|
|
// all connected clients.
|
|
void StartGame();
|
|
|
|
static MessageHandler BaseHandler;
|
|
static MessageHandler HandshakeHandler;
|
|
static MessageHandler AuthenticateHandler;
|
|
static MessageHandler PreGameHandler;
|
|
static MessageHandler ObserverHandler;
|
|
static MessageHandler ChatHandler;
|
|
static MessageHandler InGameHandler;
|
|
};
|
|
|
|
#endif
|