26 lines
992 B
Python
26 lines
992 B
Python
from flask import Blueprint, make_response, request, jsonify, session, request
|
|
from flask_socketio import SocketIO, emit, join_room, leave_room
|
|
|
|
from libs.api.eventsSocketio import EventsSocketio
|
|
|
|
import os, json
|
|
import logging
|
|
|
|
class HandlerSocketio(EventsSocketio):
|
|
def events(self):
|
|
@self.socketio.on("message", namespace=self.namespace)
|
|
def on_message(*args, **kwargs):
|
|
print('P2Post Message',args, kwargs)
|
|
self.socketio.send(f"Message from P2Post {args[0]}", namespace=self.namespace)
|
|
|
|
@self.socketio.on("ola", namespace=self.namespace)
|
|
def on_test(*args, **kwargs):
|
|
print('P2Post ola',args, kwargs)
|
|
self.socketio.emit("ola",f"Ola from P2Post {args[0]}", namespace=self.namespace)
|
|
|
|
|
|
def send_test(self, message):
|
|
self.socketio.emit("test",message, namespace=self.namespace)
|
|
|
|
def emit_new_user(self, user):
|
|
self.socketio.emit("newUser", user, namespace=self.namespace) |