27 lines
749 B
Python
27 lines
749 B
Python
from app import app
|
|
from flask_socketio import SocketIO, emit
|
|
from loguru import logger as log
|
|
#from module.db.repositories.robot_reposytory import update_robot get_by_id get_all
|
|
#from module.db.repositories.inventory_repository import get_all as getRecords
|
|
ws = socketIO(app)
|
|
|
|
@ws.on('connect')
|
|
def is_connect():
|
|
log.info('client is connected')
|
|
|
|
@ws.on('disconnect')
|
|
def is_disconnect():
|
|
log.info('client is disconnected')
|
|
|
|
@ws.on('robot_update')
|
|
def robotUpdate():
|
|
robots = get_all()
|
|
emit('response', jsonify({"type": "robot_update", "data": {robots.toJSON()}})
|
|
|
|
@ws.on('inventory_alert')
|
|
def robotUpdate():
|
|
records = getRecords()
|
|
emit('response', jsonify({"type": "inventory_alert", "data": {records.toJSON()}})
|
|
|
|
|