Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 1.31 KB

File metadata and controls

59 lines (43 loc) · 1.31 KB

Python Multiplayer

PyPI version

Framework for Client Server Structure in Python. Is intended to be used for multiplayer games in pygame with this Module.

pygame-multiplayer


Planned features

  • Command based Network
  • Threaded Network
  • Async Network

Installation

pip install python-multiplayer

Usage (Command Server/Client)

Server:

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)