Skip to content

Latest commit

 

History

History
52 lines (32 loc) · 1.06 KB

README.rst

File metadata and controls

52 lines (32 loc) · 1.06 KB

Leonardo leonardo-channels

Channels for Leonardo CMS. As an example this module has implemented django-messages.

pip install leonardo-channels
var basepath = "ws://" + window.location.hostname + ":" + window.location.port;

socket = new WebSocket(basepath + "/messages?session_key={{ request.session.session_key }}");

/* Bind django-messages */
socket.onmessage = function(e) {
    msg = JSON.parse(e.data)
    horizon.alert(msg.level, msg.message, msg.extra_tags)
}

Use from python

from leonardo_channels import router
router.route("websocket.connect", ws_add)
router.include("websocket.myroutes", path=r"/chat")

Use channels for messages

from leonardo_channels.messages import add_message
add_message(user, level, message)