diff --git a/app.py b/app.py index e43f375..d618028 100644 --- a/app.py +++ b/app.py @@ -39,7 +39,7 @@ def open_chat(channel, name): @socketio.on('new_message') def new_message(message): # Send message to alls users - emit('new_message', { + emit('channel-' + str(message['channel']), { 'username': message['username'], 'text': message['text'] }, diff --git a/envExample b/envExample index 3d54d76..03eb6d1 100644 --- a/envExample +++ b/envExample @@ -1,3 +1,4 @@ SECRET_KEY=secret DEBUG=True DATABASE="sqlite:///database.sqlite" +DOMAIN=127.0.0.1:5000 diff --git a/templates/chat.html b/templates/chat.html index e927a5f..32594ed 100644 --- a/templates/chat.html +++ b/templates/chat.html @@ -72,7 +72,7 @@ console.log('Connect') }); - socket.on('new_message', function(msg) { + socket.on('channel-' + app.channel, function(msg) { // Add new message to HTML let my_messages = app.messages; my_messages.push({