some updates
This commit is contained in:
25
handlers/socketio.py
Normal file
25
handlers/socketio.py
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
from misc.conversations import Conversations
|
||||
from flask import Flask, request
|
||||
from flask_socketio import join_room, leave_room
|
||||
|
||||
def init_socketio_handlers(socketio):
|
||||
@socketio.on('connect')
|
||||
def handle_connect():
|
||||
print('Клиент подключился')
|
||||
ip_address = request.remote_addr # Получение IP-адреса клиента
|
||||
sid = request.sid
|
||||
print(f'Клиент подключился с IP: {ip_address} SID: {sid}')
|
||||
|
||||
@socketio.on('disconnect')
|
||||
def handle_disconnect():
|
||||
print('Клиент отключился')
|
||||
|
||||
@socketio.on('new_problem')
|
||||
def handle_message(data):
|
||||
print('Получено сообщение:', data, ip_address)
|
||||
conversation = Conversations().create(data.get("message"),data.get("work_place"),data.get("name"),data.get("problem"))
|
||||
|
||||
|
||||
socketio.emit('response', {'data': conversation})
|
||||
print(data)
|
||||
Reference in New Issue
Block a user