Here's a bare minimum network story:
- you start one
mdo-cli with a --server command-line argument (server)
- you start another
mdo-cli without that argument (client)
- the client connects to the server, and sends it a username (
ExampleUsername for now)
- the server logs that connected username to the console
- the server sends out that username to all of the already connected clients
- the clients log out that username
There's no immediate need to use an advanced protocol definition format like FlatBuffers, so for this basic demo, sending simple strings in packets is fine. Remember to appropriately handle null termination.
Other than the --serverless flag passed to the CLI to select whether the server or the client is running, there's no need to provide any other configuration to the CLI to get a basic networking demo working. That can be figured out in a future issue. For now, hardcoding a localhost address and port, and using a hard username like ExampleUsername is fine.
Physical implementation:
- create
network_client and network_server objects:
include/network/network_server.h
include/network/network_client.h
src/network/network_server.c
src/network/network_client.c
- use libuv in
network_server to listen on a localhost port, handle incoming clients and safely handle remote hang-ups
- format and log strings received by
network_server (like "ExampleUsername connected") and broadcast them back out to clients
- use libuv in
network_client to connect to a localhostport, and log received strings
- in
cli/main.c, scan the arguments for --serverless using strcmp(), and initialize either network_server or network_client depending on presence of the flag
Here's a bare minimum network story:
mdo-cliwith a--servercommand-line argument (server)mdo-cliwithout that argument (client)ExampleUsernamefor now)There's no immediate need to use an advanced protocol definition format like FlatBuffers, so for this basic demo, sending simple strings in packets is fine. Remember to appropriately handle null termination.
Other than the
--serverlessflag passed to the CLI to select whether the server or the client is running, there's no need to provide any other configuration to the CLI to get a basic networking demo working. That can be figured out in a future issue. For now, hardcoding alocalhostaddress and port, and using a hard username likeExampleUsernameis fine.Physical implementation:
network_clientandnetwork_serverobjects:include/network/network_server.hinclude/network/network_client.hsrc/network/network_server.csrc/network/network_client.cnetwork_serverto listen on alocalhostport, handle incoming clients and safely handle remote hang-upsnetwork_server(like "ExampleUsername connected") and broadcast them back out to clientsnetwork_clientto connect to alocalhostport, and log received stringscli/main.c, scan the arguments for--serverlessusingstrcmp(), and initialize eithernetwork_serverornetwork_clientdepending on presence of the flag