Skip to main content

A library that makes it easy to make multiplayer

Project description

Multisocket

A library that handles all of the socket backend, While you can focus on making your application.

It's easy to set it up, Just make a Server (multisocket.server.Server) and some Clients (multisocket.client.Client), Start the server, And connect the clients to the server.

You can give the client or the server a callback function, So that you can change their behaviour!

If you give the client a callback function, It will be called every frame and be given these arguments.

client - The client that called this function. packets - All of the packets that the client recieved from the server, In a list.

This callback function can return a single packet, Or a list of them, And the client will send them to the server.

Similarly, If you give the server a callback function, It will also be called every frame, And get these arguments.

server - The server that called this function. client - The client that the packets will be sent to. packets - All of the packets that the server recieved from the client, In a list.

This callback function can also return packets to send to the client.

This is a simple script that uses multisocket to communicate between servers and clients:

from multisocketing import clients, servers
from multisocketing import packets as packetClasses
import threading

def clientLoop(client, packets):
    print("packets from server:")
    print(packets)
    return packetClasses.Packet()

def serverLoop(server, client, packets):
    print("packets from client:")
    print(packets)

def setupServer():
    s = servers.Server(Sloop)
    s.start()

def makeClient():
    c = clients.Client(Cloop)
    c.connect()

thread = threading.Thread(target=setupServer)
thread.start()

thread = threading.Thread(target=makeClient)
thread.start()

makeClient()

Hope this library makes it easier for you to make socket-related applications!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multisocketing-1.2.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

multisocketing-1.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file multisocketing-1.2.tar.gz.

File metadata

  • Download URL: multisocketing-1.2.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for multisocketing-1.2.tar.gz
Algorithm Hash digest
SHA256 be815e7bb6a055007497f38058ebb649ac551ef06a42be0659a39ff8cbc07185
MD5 ca455bd780c715bd875a0a2c5a71785b
BLAKE2b-256 7d5c84b67a2900f269f6a7ef7f3740fac3a249e3cfc4f739426189795a6b6da0

See more details on using hashes here.

File details

Details for the file multisocketing-1.2-py3-none-any.whl.

File metadata

  • Download URL: multisocketing-1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for multisocketing-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5d5b79040eeb8fab90ed9d0ffeef403ab4c17751c258aeae18e51d2a990b79a2
MD5 bdcc0688b1be77b8f96f8402c3fc8a4c
BLAKE2b-256 706cc37fb2f568c265406b5423ceacc115f8d405692679eee460b87a727f626a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page