Framework for Client Server Structure in Python. Is intended to be used for multiplayer games in pygame with this Module.
- Command based Network
- Threaded Network
- Async Network
pip install python-multiplayerServer:
from py_mp import CommandServer
from py_mp import ServerSideServerCommand
from py_mp.commands import NetworkFlag
server = CommandServer("localhost", 5000)
server.accept()
# Receive a Command from the Client
com = server.recv(server.clients[0])
print(com)
# Send a Test Command back to the Client
server.send(
ServerSideServerCommand(NetworkFlag.CONNECTED, server.clients[0], test="test"),
server.clients[0]
)Client:
from py_mp import CommandClient
from py_mp import ClientCommand
from py_mp.commands import NetworkFlag
client = CommandClient("localhost", 5000)
# Send a Test Command to the Server
client.send(ClientCommand(NetworkFlag.CONNECTED, test="test"))
# Receive a Command from the Server
com = client.recv()
print(com)