Compare commits
2 Commits
3073c4e4b5
...
21933cdef9
| Author | SHA1 | Date | |
|---|---|---|---|
| 21933cdef9 | |||
| 34a8ce730a |
@@ -305,7 +305,7 @@ class TunneldRunnerSio:
|
|||||||
elif len(active_udids) == 0:
|
elif len(active_udids) == 0:
|
||||||
logger.error("Simulation worker: no active tunnel with udid available")
|
logger.error("Simulation worker: no active tunnel with udid available")
|
||||||
await self.context.sio.emit(
|
await self.context.sio.emit(
|
||||||
"error",
|
"appError",
|
||||||
{"type": "simulation_no_tunnel", "message": "No active tunnel found. Start tunnel first."},
|
{"type": "simulation_no_tunnel", "message": "No active tunnel found. Start tunnel first."},
|
||||||
namespace="/",
|
namespace="/",
|
||||||
)
|
)
|
||||||
@@ -314,7 +314,7 @@ class TunneldRunnerSio:
|
|||||||
logger.error("Simulation worker: multiple active tunnels; explicit udid required: %s",
|
logger.error("Simulation worker: multiple active tunnels; explicit udid required: %s",
|
||||||
active_udids)
|
active_udids)
|
||||||
await self.context.sio.emit(
|
await self.context.sio.emit(
|
||||||
"error",
|
"appError",
|
||||||
{
|
{
|
||||||
"type": "simulation_udid_required",
|
"type": "simulation_udid_required",
|
||||||
"message": "Multiple active tunnels found; provide udid in start_simulate_location.",
|
"message": "Multiple active tunnels found; provide udid in start_simulate_location.",
|
||||||
@@ -349,7 +349,7 @@ class TunneldRunnerSio:
|
|||||||
self.context.udid,
|
self.context.udid,
|
||||||
)
|
)
|
||||||
await self.context.sio.emit(
|
await self.context.sio.emit(
|
||||||
"error",
|
"appError",
|
||||||
{
|
{
|
||||||
"type": "simulation_timeout",
|
"type": "simulation_timeout",
|
||||||
"udid": self.context.udid,
|
"udid": self.context.udid,
|
||||||
@@ -361,7 +361,7 @@ class TunneldRunnerSio:
|
|||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Simulation worker crashed")
|
logger.exception("Simulation worker crashed")
|
||||||
await self.context.sio.emit(
|
await self.context.sio.emit(
|
||||||
"error",
|
"appError",
|
||||||
{"type": "simulation_crash", "udid": self.context.udid},
|
{"type": "simulation_crash", "udid": self.context.udid},
|
||||||
namespace="/",
|
namespace="/",
|
||||||
)
|
)
|
||||||
|
|||||||
37
socktest.py
Normal file
37
socktest.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import uvicorn
|
||||||
|
from fastapi import FastAPI
|
||||||
|
import socketio
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
sio = socketio.AsyncServer(cors_allowed_origins="*", async_mode="asgi")
|
||||||
|
socket_app = socketio.ASGIApp(sio, app)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
def main():
|
||||||
|
return {"message": "Hello World"}
|
||||||
|
|
||||||
|
|
||||||
|
@sio.on("connect")
|
||||||
|
async def connect(sid, env):
|
||||||
|
print("New Client Connected to This id :" + " " + str(sid))
|
||||||
|
await sio.emit("message", f"Hello Client, Welcome to Socket.IO Server {sid}")
|
||||||
|
|
||||||
|
|
||||||
|
@sio.event
|
||||||
|
async def message(sid, data):
|
||||||
|
print("Message from Client: " + str(data))
|
||||||
|
return True
|
||||||
|
|
||||||
|
@sio.on("disconnect")
|
||||||
|
async def disconnect(sid):
|
||||||
|
print("Client Disconnected: " + " " + str(sid))
|
||||||
|
|
||||||
|
@sio.on('*')
|
||||||
|
async def any_event(event, sid, data):
|
||||||
|
print("Unregisered event received, event: " + str(event) + " sid: " + str(sid) + " data: " + str(data))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
uvicorn.run(
|
||||||
|
"socktest:socket_app", host="0.0.0.0", port=8000, lifespan="on", reload=True
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user