Add example

This commit is contained in:
Andros Fenollosa 2021-11-21 12:47:12 +01:00
parent 79578ff141
commit 2b30e08381
3 changed files with 23 additions and 0 deletions

View File

@ -62,6 +62,14 @@ class WebsiteConsumer(AsyncWebsocketConsumer):
self.room_group_name, {"type": "send_page_profiles"} self.room_group_name, {"type": "send_page_profiles"}
) )
# Chat
if data["value"] == "chat":
await self.channel_layer.group_send(
self.room_group_name, {
"type": "send_page_chat",
}
)
# About # About
if data["value"] == "about": if data["value"] == "about":
await self.channel_layer.group_send( await self.channel_layer.group_send(
@ -104,6 +112,14 @@ class WebsiteConsumer(AsyncWebsocketConsumer):
html = await sync_to_async(self._get_profiles)() html = await sync_to_async(self._get_profiles)()
await self.send(text_data=html) await self.send(text_data=html)
def _get_chat(self):
return page_chat()
async def send_page_chat(self, event):
"""Send Chat page"""
html = await sync_to_async(self._get_chat)()
await self.send(text_data=html)
def _get_about(self): def _get_about(self):
return page_about() return page_about()

View File

@ -36,6 +36,10 @@
{# To page Profiles #} {# To page Profiles #}
{% #link action="page" value="profiles" scroll-up="true" %}Profiles{% /link %} {% #link action="page" value="profiles" scroll-up="true" %}Profiles{% /link %}
</li> </li>
<li>
{# To page Chat #}
{% #link action="page" value="chat" scroll-up="true" %}Chat{% /link %}
</li>
<li> <li>
{# To page About #} {# To page About #}
{% #link action="page" value="about" scroll-up="true" %}About{% /link %} {% #link action="page" value="about" scroll-up="true" %}About{% /link %}

View File

@ -0,0 +1,3 @@
<main id="main" data-scroll-to-top="true">
soy el chat
</main>