Channels Multiplexer
Django Channels does not yet include a Multiplexing Consumer. This project aims to add such a multiplexer.
Version Compatibility
Channels Version |
Channels Multiplexer Version |
|---|---|
v2 |
0.0.2 |
v3 |
>=0.0.3 |
Install
pip install channelsmultiplexer
Usage
to create a De-Multiplexer
class EchoDemultiplexerAsyncJson(AsyncJsonWebsocketDemultiplexer):
applications = {
"echostream": EchoTestConsumer(),
"altechostream": AltEchoTestConsumer(),
"closeafterfirst": EchoCloseAfterFirstTestConsumer(),
"neveraccept": NeverAcceptTestConsumer()
}
or you can use the AsyncJsonWebsocketDemultiplexer type directly and pass the multiplexed upstream consumers as kwargs.
application = ProtocolTypeRouter({
"websocket": URLRouter([
url(r"^ws/$", AsyncJsonWebsocketDemultiplexer(
echostream = EchoTestConsumer(),
altechostream = AltEchoTestConsumer(),
closeafterfirst = EchoCloseAfterFirstTestConsumer(),
neveraccept = NeverAcceptTestConsumer()
)),
]),
"telegram": ChattyBotConsumer.as_asgi(),
})
This acts just as any other channels consumer, however it will route incoming (JSON) messages to the upstream Consumers.
It does this by reading the value of the stream attribute in the message body. It will then pass the value of the payload attribute upstream.
{
"stream": "echostream",
"payload": {"hello": "world"}
}
Messages being sent downstream from the Multiplexed consumers will be embedded within a similar style msg.
Metadata
Release files for channelsmultiplexer 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| channelsmultiplexer-0.0.3.tar.gz | 6.0 kB | Without provenance | Details for channelsmultiplexer-0.0.3.tar.gz |
Release files / channelsmultiplexer-0.0.3.tar.gz
| Download URL | channelsmultiplexer-0.0.3.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98e674110f07b1d41940a32d0a921156d17bf9176a65f19f71f703e3bb38f50e
|
|
BLAKE2b-256 checksum How to use checksums |
8fc91323f14fbf6916259266f0f7f749749dd0cabc59edd6fcc524a041b40a8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.1
|
Security for channelsmultiplexer 0.0.3
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.