All Projects → twtrubiks → django-chat-room

twtrubiks / django-chat-room

Licence: MIT license
chat-room 💬 use django-channels3

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects
CSS
56736 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to django-chat-room

ReaLocate
ASP.NET MVC 5 Real Estate Application
Stars: ✭ 18 (-64%)
Mutual labels:  chat-room
React-Native-Demo
No description or website provided.
Stars: ✭ 25 (-50%)
Mutual labels:  chat-room
AIO
Coroutine-based multithreading library for Delphi
Stars: ✭ 99 (+98%)
Mutual labels:  channels
darkwire-client
Encrypted web socket chat - Darkwire.io client
Stars: ✭ 23 (-54%)
Mutual labels:  chat-room
comicchat
Web client and node.js server based off Microsoft Comic Chat.
Stars: ✭ 109 (+118%)
Mutual labels:  chat-room
ChatRoom
一个在线聊天室demo,基于PHP SWOOLE,需要SWOOLE拓展的支持
Stars: ✭ 26 (-48%)
Mutual labels:  chat-room
node-chat
A demo of using socket.io + backbone.js to create a simple chatroom service.
Stars: ✭ 43 (-14%)
Mutual labels:  chat-room
dcrf-client
Javascript client for Django Channels REST Framework
Stars: ✭ 43 (-14%)
Mutual labels:  channels
The-chat-room
Python 版的多人聊天室, 图形界面版
Stars: ✭ 100 (+100%)
Mutual labels:  chat-room
ChatRoom
聊天室
Stars: ✭ 30 (-40%)
Mutual labels:  chat-room
P2P-Chat
A Peer-to-Peer chatting application created in Python.
Stars: ✭ 20 (-60%)
Mutual labels:  chat-room
chat-here
A responsive chat room based on Laravel5.4 and GatewayWorker3.0. (基于 Laravel 5.4 和 GatewayWorker 3.0 的响应式聊天室。)
Stars: ✭ 24 (-52%)
Mutual labels:  chat-room
Chat-Server
Simple chatroom in C
Stars: ✭ 74 (+48%)
Mutual labels:  chat-room
forum live-tangshan
django后台,移动app,功能有登录,支付、充值,礼物贴现申请,直播,论坛,好友,地区选择功能。
Stars: ✭ 38 (-24%)
Mutual labels:  chat-room
Bee-Connect
Ruby on Rails App. A good example of how to build social networking system with live chat support, blogging,groups etc.
Stars: ✭ 30 (-40%)
Mutual labels:  chat-room
ChatServerTCP
保密型聊天软件服务器 /Private Chat Server
Stars: ✭ 14 (-72%)
Mutual labels:  chat-room
akka-http-streaming-response-examples
A list of examples that involve streaming with Akka Streams and used together with Akka HTTP
Stars: ✭ 73 (+46%)
Mutual labels:  chat-room
DemonEditor
Enigma2 channel and satellite list editor for GNU/Linux and macOS.
Stars: ✭ 80 (+60%)
Mutual labels:  channels
go-eventcast
Simple event broadcasting
Stars: ✭ 22 (-56%)
Mutual labels:  channels
OakBot
A Java-based chat bot for Stackoverflow Chat
Stars: ✭ 37 (-26%)
Mutual labels:  chat-room

docker-django-chat-room

docker-django-chat-room use django-channels3💬

前言

這篇文章是 django-channels2-tutorial 的改良版,主要加上美化以及資料庫。

執行畫面

直接瀏覽 http://localhost:8000/chat/

alt tag

未登入無法聊天( 也無法看到聊天內容 )

alt tag

登入註冊頁面

alt tag

聊天畫面

alt tag

如何執行

確認電腦有安裝 docker 後,直接執行以下指令即可,

docker-compose up

alt tag

如何移除 ( 包含移除 volume ),

docker-compose down -v

詳細的詳細說明,在上一篇 django-channels2-tutorial 都說明過了。

其他說明

說明一

登入註冊是參考之前寫的教學完成,可參考 Django Social Login Tutorial,我有簡化一些不必要的部份,

但大多都是直接拿過來使用的。

說明二

為什麼需要使用到 reconnecting-websocket,原因是假設當 websocket 斷線時,他並不會自動重新連結,

我們可以透過這個 js ,幫我們完成當 websocket 斷線時,自動重新連線的工作。

說明三

js 中的 {{ room_name }} 用法,像是在 django_chat_room/chat/templates/chat/room.html 中的

....
$('#all_messages').scrollTop($('#all_messages')[0].scrollHeight);
var room_mame = '{{ room_name }}';
var ws_scheme = window.location.protocol == "https:" ? "wss" : "ws";
var websocket_str= ws_scheme+'://' + window.location.host + '/ws/chat/' + room_mame + '/';
var chatSocket = new ReconnectingWebSocket(websocket_str);
...

為什麼可以使用 {{ room_name }} 這種寫法,原因是 jinja2 的關係,不過這樣就不能單獨把這段 js 獨立

出來成一隻 .js 檔案,因為這樣的話 jinja2 就會失效,但如果真的硬要抽出來也是可以,我們可以把它 render

到某個 hidden 的欄位,然後再用 js 去抓他的值。

後記

依照 django-channels2-tutorial 這篇的基本觀念,延伸出一個比較完整的聊天室,

整體來說,蠻好玩的 😆 這邊一樣沒有佈署,本來想佈署到 Heroku,但因為需要用

到 redis ( 要信用卡 ),所以就沒佈署了,相關的部屬流程,可參考官網的 Deploying

執行環境

  • Python 3.8

Reference

Donation

文章都是我自己研究內化後原創,如果有幫助到您,也想鼓勵我的話,歡迎請我喝一杯咖啡😆

alt tag

贊助者付款

License

MIT licens

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].