abs-utils 0.2.4__tar.gz → 0.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. {abs_utils-0.2.4 → abs_utils-0.2.5}/PKG-INFO +1 -1
  2. abs_utils-0.2.5/abs_utils/socket_io/server.py +34 -0
  3. {abs_utils-0.2.4 → abs_utils-0.2.5}/pyproject.toml +1 -1
  4. abs_utils-0.2.4/abs_utils/socket_io/server.py +0 -21
  5. {abs_utils-0.2.4 → abs_utils-0.2.5}/README.md +0 -0
  6. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/azure_service_bus/__init__.py +0 -0
  7. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/azure_service_bus/azure_service_bus.py +0 -0
  8. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/azure_service_bus/event_decorator.py +0 -0
  9. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/constants/__init__.py +0 -0
  10. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/constants/endpoint_constants.py +0 -0
  11. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/constants/event_constants.py +0 -0
  12. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/logger/__init__.py +0 -0
  13. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/logger/logger.py +0 -0
  14. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/schemas/__init__.py +0 -0
  15. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/schemas/fields_schema/__init__.py +0 -0
  16. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/schemas/fields_schema/common_schema.py +0 -0
  17. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/schemas/fields_schema/field_schema.py +0 -0
  18. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/schemas/libs/__init__.py +0 -0
  19. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/schemas/libs/extend_enum.py +0 -0
  20. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/schemas/libs/make_optional.py +0 -0
  21. {abs_utils-0.2.4 → abs_utils-0.2.5}/abs_utils/socket_io/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: abs-utils
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: AutoBridge Systems Utility Library
5
5
  Author: AutoBridgeSystems
6
6
  Author-email: info@autobridgesystems.com
@@ -0,0 +1,34 @@
1
+ import socketio
2
+ from fastapi import FastAPI
3
+ from typing import Callable, Dict, Any
4
+ from functools import wraps
5
+ import asyncio
6
+ from ..logger import setup_logger
7
+
8
+ logger = setup_logger(__name__)
9
+ class SocketIOService:
10
+ def __init__(self, cors_origins: str = "*"):
11
+ self.sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins=cors_origins)
12
+
13
+ def bind_app(self, fastapi_app: FastAPI):
14
+ return socketio.ASGIApp(self.sio, other_asgi_app=fastapi_app)
15
+
16
+ async def emit_to_sid(self, sid: str, event: str, data: Dict[str, Any]):
17
+ await self.sio.emit(event, data, to=sid)
18
+
19
+ async def emit_broadcast(self, event: str, data: Dict[str, Any],namespace:str=None):
20
+ if namespace:
21
+ await self.sio.emit(event, data,namespace=namespace)
22
+ else:
23
+ await self.sio.emit(event, data)
24
+
25
+ async def join_room(self, sid: str, room: str):
26
+ await self.sio.enter_room(sid, room)
27
+ logger.info(f"{sid} joined room {room}")
28
+
29
+ async def leave_room(self, sid: str, room: str):
30
+ await self.sio.leave_room(sid, room)
31
+ logger.info(f"{sid} left room {room}")
32
+
33
+ async def emit_to_room(self, event: str, room: str, data: Dict[str, Any], namespace: str = None):
34
+ await self.sio.emit(event, data, room=room, namespace=namespace)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "abs-utils"
3
- version = "0.2.4"
3
+ version = "0.2.5"
4
4
  description = "AutoBridge Systems Utility Library"
5
5
  authors = [
6
6
  {name = "AutoBridgeSystems", email = "info@autobridgesystems.com"}
@@ -1,21 +0,0 @@
1
- import socketio
2
- from fastapi import FastAPI
3
- from typing import Callable, Dict, Any
4
- from functools import wraps
5
- import asyncio
6
-
7
-
8
- class SocketIOService:
9
- def __init__(self, cors_origins: str = "*"):
10
- self.sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins=cors_origins)
11
-
12
- def bind_app(self, fastapi_app: FastAPI):
13
- return socketio.ASGIApp(self.sio, other_asgi_app=fastapi_app)
14
-
15
- async def emit_to_sid(self, sid: str, event: str, data: Dict[str, Any]):
16
- """Emit directly to a specific client."""
17
- await self.sio.emit(event, data, to=sid)
18
-
19
- async def emit_broadcast(self, event: str, data: Dict[str, Any]):
20
- """Emit to all clients."""
21
- await self.sio.emit(event, data)
File without changes