![]() |
||||||||
|
|
||||||||
This class represents one host in the network. It manages ZCom_Nodes, connections, bandwidth distribution, etc. For localhost games, two ZCom_Controls should be present in one process, communicating through an eZCom_SocketLocal type socket.
Public Member Functions | |
| void | Shutdown (void) |
| Free all resources. | |
| ZCom_ClassID | ZCom_getClassID (const char *_name) const |
| Retrieve class ID of registered class. | |
| const ZCom_ConnStats & | ZCom_getConnectionStats (ZCom_ConnID _id) const |
| Get connection statistics. | |
| ZCom_Node * | ZCom_getNode (ZCom_NodeID _nid) const |
| Retrieve node by unique net id. | |
| const ZCom_Address * | ZCom_getPeer (ZCom_ConnID _id) const |
| Get remoteaddress of connection. | |
| void * | ZCom_getUserData (ZCom_ConnID _id) const |
| Retrieve userdata from a connection. | |
| bool | ZCom_initSockets (bool _useudp, zU16 _udpport, zU16 _localport, zU8 _control_id_size=0) |
| Create the local sockets. | |
| void | ZCom_processInput (eZCom_BlockMode _block=eZCom_NoBlock) |
| Process incoming data. | |
| void | ZCom_processOutput () |
| Prepare and send updates. | |
| void | ZCom_processReplicators (zU32 _simulation_time_passed) |
| ZCom_ClassID | ZCom_registerClass (const char *_name, zU32 _class_flags=0) |
| Register a new class. | |
| void | ZCom_setControlID (zU8 _id) |
| Set this ZCom_Control's control ID. | |
| void | ZCom_setDebugName (const char *_name) |
| Set name shown in logoutput. | |
| bool | ZCom_setDiscoverListener (eZCom_DiscoverOpt _opt, zU16 _discoverport) |
| Set how control reacts to discover requests. | |
| void | ZCom_setUpstreamLimit (zU32 _total_bps, zU32 _perconn_bps) |
| Limit outbound traffic in total and per connection, set to 0 to disable limit. | |
| void | ZCom_setUserData (ZCom_ConnID _id, void *_data) |
| Attach userdata to a connection. | |
| virtual | ~ZCom_Control (void) |
| Destructor. | |
Callbacks | |
| |
| virtual void | ZCom_cbConnectionClosed (ZCom_ConnID _id, eZCom_CloseReason _reason, ZCom_BitStream &_reasondata)=0 |
| Callback: connection has been closed and is about to be deleted (appears on: Server, Client). | |
| virtual bool | ZCom_cbConnectionRequest (ZCom_ConnID _id, ZCom_BitStream &_request, ZCom_BitStream &_reply)=0 |
| Callback: incoming connection. (appears on: Server). | |
| virtual void | ZCom_cbConnectionSpawned (ZCom_ConnID _id)=0 |
| Callback: a granted, incoming connection has been fully set up. (appears on: Server). | |
| virtual void | ZCom_cbConnectResult (ZCom_ConnID _id, eZCom_ConnectResult _result, ZCom_BitStream &_reply)=0 |
| Callback: connection process finished. (appears on: Client). | |
| virtual void | ZCom_cbDataReceived (ZCom_ConnID _id, ZCom_BitStream &_data)=0 |
| Callback: direct data has been received. (appears on: Server, Client). | |
| virtual void | ZCom_cbDiscovered (const ZCom_Address &_addr, ZCom_BitStream &_reply)=0 |
| Callback: another ZCom_Control responded to our ZCom_Discover(). (appears on: Server, Client). | |
| virtual bool | ZCom_cbDiscoverRequest (const ZCom_Address &_addr, ZCom_BitStream &_request, ZCom_BitStream &_reply)=0 |
| Callback: another ZCom_Control has sent a discover request. (appears on: Server, Client). | |
| virtual void | ZCom_cbNodeRequest_Dynamic (ZCom_ConnID _id, ZCom_ClassID _requested_class, ZCom_BitStream *_announcedata, eZCom_NodeRole _role, ZCom_NodeID _net_id)=0 |
| Callback: server requests us to create a new node for a new dynamic object/node. (appears on: Client). | |
| virtual void | ZCom_cbNodeRequest_Tag (ZCom_ConnID _id, ZCom_ClassID _requested_class, ZCom_BitStream *_announcedata, eZCom_NodeRole _role, zU32 _tag)=0 |
| Callback: server requests us to create a new local node for a remote tagnode (appears on: Client). | |
| virtual bool | ZCom_cbZoidRequest (ZCom_ConnID _id, zU8 _requested_level, ZCom_BitStream &_reason)=0 |
| Callback: a client requests to enter a specified ZoidLevel. (appears on: Server). | |
| virtual void | ZCom_cbZoidResult (ZCom_ConnID _id, eZCom_ZoidResult _result, zU8 _new_level, ZCom_BitStream &_reason)=0 |
| Callback: Zoidlevel migration process finished (appears on: Server, Client). | |
Connection handling. | |
| ZCom_ConnID | ZCom_Connect (const ZCom_Address &_target, ZCom_BitStream *_request) |
| Initiate connection to other ZCom_Control. | |
| bool | ZCom_Disconnect (const ZCom_ConnID _id, ZCom_BitStream *_reason) |
| Send disconnect request. | |
| void | ZCom_disconnectAll (ZCom_BitStream *_reason) |
| Request disconnect for all connections. | |
| bool | ZCom_Discover (const ZCom_Address &_address, ZCom_BitStream *_request) |
| Find other ZCom_Controls by sending a broadcast into the LAN. | |
| ZCom_ConnGroupManager & | ZCom_getGroupManager () |
| Returns this control's connection group manager. | |
| void | ZCom_requestDownstreamLimit (ZCom_ConnID _id, zU16 _pps, zU16 _bpp) |
| Request the quality of incoming traffic. | |
| bool | ZCom_requestZoidMode (const ZCom_ConnID _id, zU8 _level) |
| Bring connection into Zoidmode. | |
| bool | ZCom_sendData (const ZCom_ConnID _id, ZCom_BitStream *_stream, eZCom_SendMode _mode=eZCom_ReliableOrdered) |
| Simple way to send some data. | |
| bool | ZCom_sendDataRaw (ZCom_Address &_dest, void *_data, zU32 _size) |
| Send raw UDP datagram to some address. | |
| bool | ZCom_sendDataToGroup (const ZCom_GroupID _gid, ZCom_BitStream *_stream, eZCom_SendMode _mode) |
| Send data to a group of connections. | |
Debug aids. | |
| void | ZCom_simulateLag (ZCom_ConnID _id, zU32 _lagmsec) |
| void | ZCom_simulateLoss (ZCom_ConnID _id, zFloat _amount) |
Static Public Member Functions | |
| static ZCom_BitStream * | ZCom_createBitStream () |
| Create a new ZCom_BitStream object. | |
| static void | ZCom_deleteBitStream (ZCom_BitStream *_bs) |
| Delete a ZCom_BitStream object. | |
| static zU32 | ZCom_getCurrentTime () |
|
|
Destructor. It is advised to call ZCom_disconnectAll() before deleting a running ZCom_Control. That way it is possible to send a disconnect reason to the connected peers. This destructor will call ZCom_disconnectAll(), too, but without sending disconnect reason information. |
|
|
Free all resources. Called by the destructor. If you want to free resources before the destructor gets called use this. This is if you for example need to make sure all replicators are deleted at a certain point. Although you deleted all nodes already, Zoidcom keeps them internally until connected peers have been notified about it, and due to that, the replicators will get deleted late, too.
|
|
|
Set name shown in logoutput.
|
|
||||||||||||||||||||
|
Create the local sockets.
|
|
||||||||||||
|
Set how control reacts to discover requests.
When an incoming discover request is received, the callback ZCom_cbDiscoverRequest() is called. Default is no broadcast listening. |
|
|
Set this ZCom_Control's control ID.
=> ZCom_Controls which want to communicate with each other need the same ID size, which is set on a per socket basis, see zoidcom_socket.h. => This is another layer above the TCP/UDP port concept, making it easy to make do with just one single real UDP port. |
|
||||||||||||
|
Limit outbound traffic in total and per connection, set to 0 to disable limit.
|
|
||||||||||||
|
Register a new class.
|
|
|
Retrieve class ID of registered class.
|
|
|
Process incoming data.
|
|
|
Process replicators.
Currently only ZCom_Replicate_Movement makes use of the _simulation_time_passed parameter.
|
|
|
Prepare and send updates. Must be called regularly. |
|
|
Create a new ZCom_BitStream object.
|
|
|
Delete a ZCom_BitStream object.
|
|
||||||||||||
|
Initiate connection to other ZCom_Control.
|
|
||||||||||||||||
|
Request the quality of incoming traffic.
|
|
||||||||||||
|
Find other ZCom_Controls by sending a broadcast into the LAN.
|
|
||||||||||||
|
Send disconnect request.
|
|
|
Request disconnect for all connections.
|
|
|
Returns this control's connection group manager.
|
|
||||||||||||||||
|
Simple way to send some data.
Zoidcom will take over the stream and delete it eventually, so it has to be allocated with ZCom_createBitStream(), furthermore it should not be used or accessed in any way after that. Also note that Zoidcom is currently not splitting the datastream up into several smaller ones. If the stream holds 100k, a 100k sized UDP packet will be sent. The destination will receive the data with the ZCom_cbDataReceived() callback. |
|
||||||||||||||||
|
Send data to a group of connections.
For more verbose information look at ZCom_sendData(). |
|
||||||||||||||||
|
Send raw UDP datagram to some address.
If the address is not resolved to IP yet, the function will block and try to resolve the IP (with timeout of 2 seconds). That means the function might block for two seconds, if it gets an unresolved address. You can resolve the hostname manually (and asychronously) by calling ZCom_Address::resolveHostname() before passing the address to this function. Or specify an IP directly instead of hostname. |
|
||||||||||||
|
Bring connection into Zoidmode.
Furthermore it is possible to have different levels in Zoidmode. You can create ZCom_Nodes and tell them only to be active in specific levels. This is essentially a filter for ZCom_Nodes. A connection on a level only receives ZCom_Nodes registered at the same level. One connection can be in only one Zoidlevel, but one ZCom_Node can be registered for more than one. This works on client and server. When called from server, the ZCom_cbZoidRequest() callback won't be called. |
|
|
Retrieve node by unique net id.
|
|
|
Get remoteaddress of connection.
|
|
|
Get connection statistics.
|
|
||||||||||||
|
Attach userdata to a connection.
|
|
|
Retrieve userdata from a connection.
|
|
|
Get Zoidcom's time.
|
|
||||||||||||
|
Set the amount of lag that should be simulated for this connection.
|
|
||||||||||||
|
Set the amount of packets that should get dropped.
|
|
||||||||||||||||
|
Callback: connection process finished. (appears on: Client).
|
|
||||||||||||||||
|
Callback: incoming connection. (appears on: Server).
|
|
|
Callback: a granted, incoming connection has been fully set up. (appears on: Server).
|
|
||||||||||||||||
|
Callback: connection has been closed and is about to be deleted (appears on: Server, Client).
|
|
||||||||||||||||
|
Callback: a client requests to enter a specified ZoidLevel. (appears on: Server).
|
|
||||||||||||||||||||
|
Callback: Zoidlevel migration process finished (appears on: Server, Client).
|
|
||||||||||||||||||||||||
|
Callback: server requests us to create a new node for a new dynamic object/node. (appears on: Client).
|
|
||||||||||||||||||||||||
|
Callback: server requests us to create a new local node for a remote tagnode (appears on: Client).
|
|
||||||||||||
|
Callback: direct data has been received. (appears on: Server, Client).
|
|
||||||||||||||||
|
Callback: another ZCom_Control has sent a discover request. (appears on: Server, Client).
|
|
||||||||||||
|
Callback: another ZCom_Control responded to our ZCom_Discover(). (appears on: Server, Client).
|
1.4.6-NO