# 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:
```python
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(serverLoop)
s.start()
def makeClient():
c = clients.Client(clientLoop)
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!
(Seems like I had to re-build this 3 times just to fix the README...)
Raw data
{
"_id": null,
"home_page": null,
"name": "multisocketing",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python, multiplayer, server, client, networking, host, sockets",
"author": "ticks",
"author_email": "<khaldbedoor@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/98/52/920f92bbdecd77705e2600ea763fff24e46a7e5d9e52f7baa01341e31658/multisocketing-1.3.tar.gz",
"platform": null,
"description": "# Multisocket\r\nA library that handles all of the socket backend, While you can focus on making your application.\r\n\r\nIt's easy to set it up, Just make a Server (multisocket.server.Server) and some Clients (multisocket.client.Client),\r\nStart the server, And connect the clients to the server.\r\n\r\nYou can give the client or the server a callback function, So that you can change their behaviour!\r\n\r\nIf you give the client a callback function, It will be called every frame and be given these arguments.\r\n\r\nclient - The client that called this function.\r\npackets - All of the packets that the client recieved from the server, In a list.\r\n\r\nThis callback function can return a single packet, Or a list of them, And the client will send them to the server.\r\n\r\n\r\nSimilarly, If you give the server a callback function, It will also be called every frame, And get these arguments.\r\n\r\nserver - The server that called this function.\r\nclient - The client that the packets will be sent to.\r\npackets - All of the packets that the server recieved from the client, In a list.\r\n\r\nThis callback function can also return packets to send to the client.\r\n\r\n\r\nThis is a simple script that uses multisocket to communicate between servers and clients:\r\n```python\r\nfrom multisocketing import clients, servers\r\nfrom multisocketing import packets as packetClasses\r\nimport threading\r\n\r\ndef clientLoop(client, packets):\r\n print(\"packets from server:\")\r\n print(packets)\r\n return packetClasses.Packet()\r\n\r\ndef serverLoop(server, client, packets):\r\n print(\"packets from client:\")\r\n print(packets)\r\n\r\ndef setupServer():\r\n s = servers.Server(serverLoop)\r\n s.start()\r\n\r\ndef makeClient():\r\n c = clients.Client(clientLoop)\r\n c.connect()\r\n\r\nthread = threading.Thread(target=setupServer)\r\nthread.start()\r\n\r\nthread = threading.Thread(target=makeClient)\r\nthread.start()\r\n\r\nmakeClient()\r\n```\r\n\r\nHope this library makes it easier for you to make socket-related applications!\r\n\r\n(Seems like I had to re-build this 3 times just to fix the README...)\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A library that makes it easy to make multiplayer",
"version": "1.3",
"project_urls": null,
"split_keywords": [
"python",
" multiplayer",
" server",
" client",
" networking",
" host",
" sockets"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d8778d793e3a9f590cd2d699cda8b99c77ed71cf049374e49b481b4333062f83",
"md5": "e14da1f209549299deb49196abbd624c",
"sha256": "7f23a95da5c324888155b09cc4ffb94f292dc62b3bb1c63be5e8fc476480ca0d"
},
"downloads": -1,
"filename": "multisocketing-1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e14da1f209549299deb49196abbd624c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5571,
"upload_time": "2024-09-26T14:17:05",
"upload_time_iso_8601": "2024-09-26T14:17:05.153251Z",
"url": "https://files.pythonhosted.org/packages/d8/77/8d793e3a9f590cd2d699cda8b99c77ed71cf049374e49b481b4333062f83/multisocketing-1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9852920f92bbdecd77705e2600ea763fff24e46a7e5d9e52f7baa01341e31658",
"md5": "2b3281ce8c072c0a247b3a99ec962c06",
"sha256": "20f4004575166fadc955c33152f6352a1a63e63f0e79b0d6ad4b4a823fafd63e"
},
"downloads": -1,
"filename": "multisocketing-1.3.tar.gz",
"has_sig": false,
"md5_digest": "2b3281ce8c072c0a247b3a99ec962c06",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4140,
"upload_time": "2024-09-26T14:17:07",
"upload_time_iso_8601": "2024-09-26T14:17:07.227482Z",
"url": "https://files.pythonhosted.org/packages/98/52/920f92bbdecd77705e2600ea763fff24e46a7e5d9e52f7baa01341e31658/multisocketing-1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-26 14:17:07",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "multisocketing"
}