Skip to main content

PyPI issues Python Version GitHub release (latest by date including pre-releases) License star downloads Code style: black

SocketIO Driver

It's an extra broadcast driver support for SocketIO in masonite 4, it extends default masonite broadcast driver to support SocketIO.

Masonite Broadcast Server and Client Library

Setup

Install package using pip:

pip install masonite-socketio-driver

Add provider inside config/providers.py.

from socketio_driver.providers import SocketProvider

PROVIDERS = [
    ...,
    # Application Providers
    SocketProvider,
]

Driver Config Add following configuration inside config/broadcast.py after "pusher": {...},

"pusher": {...},
"socketio": {
    "driver": "socketio",
    "host": env("BROADCAST_HOST", "localhost"),
    "port": env("BROADCAST_PORT", "6379")
},

Add following keys in .env.

BROADCAST_HOST=
BROADCAST_PORT=

Update the broadcast driver value to socketio in .env

BROADCAST_DRIVER=socketio

Example

# broadcast to given channels

from masonite.controllers import Controller
from masonite.broadcasting import Broadcast

class YourController(Controller):

    def your_function(self, broadcast: Broadcast):
        broadcast_data = {
            "message": "Hello World"
        }
        broadcast.channel(["channel-name"], "event-name", broadcast_data)
# broadcast to selected users/clients

from masonite.controllers import Controller
from masonite.broadcasting import Broadcast
from socketio_driver.facades import Communicator

class YourController(Controller):

    def your_function(self, broadcast: Broadcast):
        broadcast_data = {
            "message": "Hello World"
        }
        clients = Communicator.clients()
        ids = [client.socketID for client in clients]
        broadcast.channel(ids, "event-name", broadcast_data)


    def or_another_function(self, broadcast: Broadcast):
        broadcast_data = {
            "message": "Hello World"
        }
        clients = Communicator.clients()
        broadcast.driver("socketio").user(clients[0]).send("event-name", broadcast_data)

Helpers

Facade helpers...

from socketio_driver.facades import Communicator
# List all clients:  
Communicator.clients()
# Get client by sessionID
Communicator.client(id='client-session-id')
# Delete all clients
Communicator.delete_all_clients()
# Delete client by SocketClient instance
Communicator.delete(client)

Metadata

Release files for masonite-socketio-driver 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for masonite-socketio-driver 2.1.0
File Size Uploaded Provenance Actions
masonite-socketio-driver-2.1.0.tar.gz 7.0 kB Without provenance Details for masonite-socketio-driver-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for masonite-socketio-driver 2.1.0
File Interpreter ABI Platform Actions
masonite_socketio_driver-2.1.0-py3-none-any.whl Python 3 none any Details for masonite_socketio_driver-2.1.0-py3-none-any.whl

Total release size: 15.3 kB

Release files / masonite-socketio-driver-2.1.0.tar.gz

Download URL masonite-socketio-driver-2.1.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e8f326d65e405b93bae8eddb9acd9886742a820815c8e6961898da5e019dd824
BLAKE2b-256 checksum
How to use checksums
68e3a462eb0b3f0c498983f43c989f5d5f4085547f0d23d0b77f3b37e650768b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / masonite_socketio_driver-2.1.0-py3-none-any.whl

Download URL masonite_socketio_driver-2.1.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ace4674cb285de3596114d3e01e9039d53daed57099434cb1010c615df873e18
BLAKE2b-256 checksum
How to use checksums
9cd14521ccd161dc1b579ff3dc6c8fe21f514f4426905a706cf12bb552c55b9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Security for masonite-socketio-driver 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page