2004-08-16 17:19:17 +02:00
|
|
|
#ifndef _Network_NetClient_H
|
|
|
|
#define _Network_NetClient_H
|
|
|
|
|
|
|
|
#include <CStr.h>
|
|
|
|
#include <Network/Session.h>
|
|
|
|
|
|
|
|
#include "TurnManager.h"
|
|
|
|
#include "Game.h"
|
2005-01-17 05:52:02 +01:00
|
|
|
#include "scripting/ScriptableObject.h"
|
|
|
|
|
2004-08-16 17:19:17 +02:00
|
|
|
class CPlayer;
|
|
|
|
|
2005-01-17 05:52:02 +01:00
|
|
|
class CNetClient: public CNetSession, protected CTurnManager, public CJSObject<CNetClient>
|
2004-08-16 17:19:17 +02:00
|
|
|
{
|
2005-01-17 05:52:02 +01:00
|
|
|
CStrW m_Password;
|
2004-08-16 17:19:17 +02:00
|
|
|
|
|
|
|
CPlayer *m_pLocalPlayer;
|
|
|
|
CGame *m_pGame;
|
|
|
|
CGameAttributes *m_pGameAttributes;
|
|
|
|
|
2005-01-17 05:52:02 +01:00
|
|
|
// JS event scripts
|
|
|
|
CScriptObject m_OnStartGame;
|
|
|
|
CScriptObject m_OnChat;
|
2005-01-19 23:32:25 +01:00
|
|
|
CScriptObject m_OnConnectComplete;
|
2005-01-17 05:52:02 +01:00
|
|
|
|
2004-08-16 17:19:17 +02:00
|
|
|
protected:
|
|
|
|
virtual void NewTurn();
|
|
|
|
virtual void QueueLocalCommand(CNetMessage *pMsg);
|
|
|
|
|
|
|
|
void StartGame();
|
|
|
|
|
|
|
|
public:
|
|
|
|
CNetClient(CGame *pGame, CGameAttributes *pGameAttribs);
|
2005-01-17 05:52:02 +01:00
|
|
|
virtual ~CNetClient();
|
2004-08-16 17:19:17 +02:00
|
|
|
|
|
|
|
inline void SetLoginInfo(CStrW nick, CStr password)
|
|
|
|
{
|
|
|
|
m_Name=nick;
|
|
|
|
m_Password=password;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MessageHandler ConnectHandler;
|
|
|
|
static MessageHandler HandshakeHandler;
|
|
|
|
static MessageHandler AuthenticateHandler;
|
|
|
|
static MessageHandler PreGameHandler;
|
|
|
|
static MessageHandler ChatHandler;
|
2004-09-21 16:40:43 +02:00
|
|
|
static MessageHandler InGameHandler;
|
2005-01-17 05:52:02 +01:00
|
|
|
|
|
|
|
bool JSI_BeginConnect(JSContext *cx, uintN argc, jsval *argv);
|
2004-08-16 17:19:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern CNetClient *g_NetClient;
|
|
|
|
|
|
|
|
#endif //_Network_NetClient_H
|