-
Notifications
You must be signed in to change notification settings - Fork 1
/
NetWorld.h
86 lines (66 loc) · 2.87 KB
/
NetWorld.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once
#ifndef NETWORLD_H_
#define NETWORLD_H_
#include "BaseWorld.h"
#include "Camera.h"
#include "NetObject.h"
namespace Sarona
{
class NetWorld
: public BaseWorld<NetWorld, NetObject>
, public IEventReceiver
{
scoped_ptr<Camera> m_camera;
boost::thread m_thread;
ptr_vector<NetObject> m_objects;
std::bitset<256> m_keystate;
void CreateV8Context();
// Connection management
bool ZCom_cbConnectionRequest(ZCom_ConnID _id, ZCom_BitStream &_request, ZCom_BitStream &_reply);
void ZCom_cbConnectionSpawned( ZCom_ConnID _id );
void ZCom_cbConnectionClosed( ZCom_ConnID _id, eZCom_CloseReason _reason, ZCom_BitStream &_reasondata );
void ZCom_cbConnectResult( ZCom_ConnID _id, eZCom_ConnectResult _result, ZCom_BitStream &_reply );
void ZCom_cbDataReceived( ZCom_ConnID _id, ZCom_BitStream &_data );
bool ZCom_cbZoidRequest( ZCom_ConnID _id, zU8 _requested_level, ZCom_BitStream &_reason );
void ZCom_cbZoidResult( ZCom_ConnID _id, eZCom_ZoidResult _result, zU8 _new_level, ZCom_BitStream &_reason );
void ZCom_cbNodeRequest_Dynamic( ZCom_ConnID _id, ZCom_ClassID _requested_class, ZCom_BitStream *_announcedata,
eZCom_NodeRole _role, ZCom_NodeID _net_id );
void ZCom_cbNodeRequest_Tag( ZCom_ConnID _id, ZCom_ClassID _requested_class, ZCom_BitStream *_announcedata,
eZCom_NodeRole _role, zU32 _tag );
bool ZCom_cbDiscoverRequest( const ZCom_Address &_addr, ZCom_BitStream &_request,
ZCom_BitStream &_reply );
void ZCom_cbDiscovered( const ZCom_Address & _addr, ZCom_BitStream &_reply );
// Node event interceptor interface
bool recUserEvent(ZCom_Node *_node, ZCom_ConnID _from,
eZCom_NodeRole _remoterole, ZCom_BitStream &_data,
zU32 _estimated_time_sent);
bool recInit(ZCom_Node *_node, ZCom_ConnID _from,
eZCom_NodeRole _remoterole);
bool recSyncRequest(ZCom_Node *_node, ZCom_ConnID _from,
eZCom_NodeRole _remoterole);
bool recRemoved(ZCom_Node *_node, ZCom_ConnID _from,
eZCom_NodeRole _remoterole);
bool recFileIncoming(ZCom_Node *_node, ZCom_ConnID _from,
eZCom_NodeRole _remoterole, ZCom_FileTransID _fid,
ZCom_BitStream &_request);
bool recFileData(ZCom_Node *_node, ZCom_ConnID _from,
eZCom_NodeRole _remoterole, ZCom_FileTransID _fid) ;
bool recFileAborted(ZCom_Node *_node, ZCom_ConnID _from,
eZCom_NodeRole _remoterole, ZCom_FileTransID _fid) ;
bool recFileComplete(ZCom_Node *_node, ZCom_ConnID _from,
eZCom_NodeRole _remoterole, ZCom_FileTransID _fid);
ZCom_ConnID m_serverConnectionId;
// Set key press status, send update to network
void UpdateKeyState(u8 keycode, bool pressed);
// Remove objects scheduled for deletion
void RemoveZombies();
public:
NetWorld(IrrlichtDevice * dev);
~NetWorld();
void Connect(string host, bool local);
void Loop();
bool OnEvent(const SEvent & event );
bool CheckKey(u8 keycode);
};
}
#endif