This commit is contained in:
Alex 2018-06-03 15:34:11 +02:00
parent 85a1298e63
commit bdd5ac3ddc
2 changed files with 7 additions and 2 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -379,10 +379,14 @@ def page_not_found(error):
"""Custom 404 page."""
return render_template('404.html'), 404
### SOCKET for the chat
@socketio.on('new_message')
def new_message(message):
# Send message to alls users
print("new message")
# Send message to all users
# print("new message")
# channel is always 1 now, but might be interesting for further development
emit('channel-' + str(message['channel']), {
'username': message['username'],
'text': message['text'],
@ -394,6 +398,7 @@ def new_message(message):
my_new_chat = Chat(
message=message['text']
)
db.session.add(my_new_chat)
try:
db.session.commit()