lucadestudios team mailing list archive
-
lucadestudios team
-
Mailing list archive
-
Message #00011
Detailed networking API design
I've been working on the design a bit more and have come up with a
list of classes/interfaces and I've got a fair idea how it's all going
to work, The next step is to develop some interfaces and unit tests
before writing the concrete code. Here are the classes I've come up
with:
CLASSES/INTERFACES
namespace network;
//Responsibility - node factory
controller_interface
initialize() : bool
spawn_packet<T>() : T*
run_server() : server_interface*
run_client() : client_interface*
shutdown() : void
node_interface
receive()
send()
attach_observer(node_observer_interface*)
remove_observer(node_observer_interface*)
//Responsibility – running a server process
server_interface : node_interface
listen_for_clients(max_clients=1) : bool
is_running() : bool
get_connected_count() : unsigned int
get_max_client_count() : unsigned int
has_queued_outgoing() : bool
//Responsibility – handle node events
node_observer_interface
on_packet_received(abstract_packet* p);
on_packet_sent(abstract_packet* p);
on_disconnected();
on_connected();
packet_header //structure used by the connection, internal
abstract_packet
//holds packet_header
//holds packet_serializer
get_unique_id() : unsigned int
serialize() : const char*
//Responsibility – to turn a packet into a stream of bytes ready
//to send across the network (probably using boost,serialization)
packet_serializer_interface
serialize_packet(abstract_packet* p) : const char*
//Responsibility – to run a thread which communicates with remote nodes
abstract_node_process
run()
Follow ups