Just a tiny, simple and realtime websocket based pub/sub messaging service using redis as backend.
- No dependencies !
- Light and Tiny.
- Uses Redis as Pub/Sub backend.
- A client can listen on any redis channel with no hassle.
- You can handle the user authentication using a simple
webhook
. - You can set a message to only be sent to certain users.
Wsify
contains ahttp
server.- That http server translate the request
path
i.e/some/channel/
to a redis channelsome/channel
. - After the client requests
ws://wsify.dev/some/channel/
thewsify
server will send a request to awebhook
to just authenticate the request. - The
webhook
will recieve theAuthorization
headerBearer XXXXXXX
and a query paramchannel
that will contains the requested channel. - In the
webhook
you do your own logic to tellwsify
that this client is authorized or not by simple returns a status code200
in case of success, or anything else to block the user. - To publish a message you need to
redis-cli> PUBLISH some/channel '{"payload": "hi", "to": []}'
this will publish the payload "hi" to all the subscribers on that channelsome/channel
. - To only send it to certain users, you will need to specify the target(s) tokens in the
to
fieldredis-cli> PUBLISH some/channel '{"payload": "hi", "to": ["Bearer XXXXXX"]}'.
- Docker ? >
docker run --network host alash3al/wsify -listen :8080 -auth-webhook "http://localhost/auth.php"
- Binary ? > goto the releases page and download yours.
- From Source ? >
go get -u github.com/alash3al/wsify
This project has been created by Mohamed Al Ashaal a Crazy Gopher ^^!
- Fork the Repo
- Create a feature branch
- Push your changes to the created branch
- Create a pull request.
This code is under MIT license ...