Possible project structures¶
This page will show you different ways of structuring your project, when you work with the pynetworking library.
At the beginning there are all different approaches with their advantages and disadvantages. After that there is a more detailed explanation of every structure.
Name | Advantages | Disadvantages | Use cases |
---|---|---|---|
Single file |
|
|
|
Client, interface, server |
|
|
|
2 interfaces |
|
|
|
Single file¶
All Code is packed in a single file. This is good for seeing fast results and testing. You only need to run one program and not two. Because of this, it is not possible to apply it to a real world application, because the server and client are always separated. To see a implementation of this structure have a look at the single_file example in the pynetworking_examples package at github.
Client, interface, server¶
Three files Client.py, Server.py, Interface.py at server and client.
Client.py: The client is started here and client-side functions are defined here.
Interface.py: Most of the pynetworking important setup stuff is here. For example the necessary Functions classes, that define which functions are available at the client and the server.
Server.py: The server is started here and server-side functions are defined here.
Of course you can add more files and import them to the interface. But the basic idea is important, that you split your server and client code and have one interface file. To see a implementation of this structure have a look at the client_interface_server example in the pynetworking_examples package at github.
2 interfaces¶
Two separate interface files. One for the client-side one for the server-side. To see a implementation of this structure have a look at the following examples: Version 2 or Version 2.1