Python networking library perfect for use with pygame!
Project description
Python networking library perfect for use with pygame!
on server-side you must create a server using the Server
class
follow the example below!
be sure to replace 192.168.1.52
with a string containing the server IP
and replace 8080
with an integer containing the server port
from pygame_networking import Server
server = Server()
server.serve(("192.168.1.52", 8080))
To create data that is synced across all clients, You can use the sync
method
from pygame_networking import Server
server = Server()
server.sync("my_variable", "my_data")
server.serve(("192.168.1.52", 8080))
replace "my_variable" with a string containing the name you want
replace "my_data" with a string containing the data the variable is initialized with
NOTE: variable data must always be string, this module does not support any other types
On client-side you must use the connect
method to establish a connection with the server
from pygame_networking import Server
server = Server()
server.connect(("192.168.1.52", 8080))
You can also use sync
from client-side to declare new variables
from pygame_networking import Server
server = Server()
server.connect(("192.168.1.52", 8080))
server.sync("my_variable", "my_data")
use get
and set
to retrieve and modify variables
from pygame_networking import Server
server = Server()
server.connect(("192.168.1.52", 8080))
server.set("count", "1")
print(server.get("count"))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pygame_networking-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 034118771f20b3bec9bdb3ce9481256af13be916aaa5c0305171056b0e00df03 |
|
MD5 | 8ddd9a1eee23473e489d9caf9676a961 |
|
BLAKE2b-256 | 0a4afdd2dec992f659f6ed191d62a475a3451e4c133e4049927015ca80cb30ed |