phystack-hub-client 0.2.3__tar.gz → 0.2.4__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.
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/PKG-INFO +1 -1
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/pyproject.toml +1 -1
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/client.py +4 -4
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/twin_messaging.py +12 -4
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/.gitignore +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/README.md +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/examples/browser_test_backend.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/scripts/python-node-test.sh +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/scripts/webrtc-test.sh +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/__init__.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/instances/__init__.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/instances/base_instance.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/instances/edge_instance.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/instances/peripheral_instance.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/services/__init__.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/services/phyhub_connection.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/services/signals.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/services/webrtc/__init__.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/services/webrtc/data_channel.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/services/webrtc/media_stream.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/twin_registry.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/types/__init__.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/types/twin_types.py +0 -0
- {phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/tests/test_communication.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: phystack-hub-client
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Python client for PhyHub - events, actions, DataChannel, and MediaStream
|
|
5
5
|
Project-URL: Homepage, https://github.com/phystack/phystack-pypi
|
|
6
6
|
Project-URL: Documentation, https://docs.phystack.com
|
|
@@ -414,10 +414,10 @@ class PhyHubClient:
|
|
|
414
414
|
"sourceDeviceId": self._connection.device_id,
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
#
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
417
|
+
# Send subscription request with ack (matches Node.js behavior)
|
|
418
|
+
return await self._emit_to_socket(
|
|
419
|
+
self.EVENTS.TWIN_SUBSCRIBE, payload, callback=True
|
|
420
|
+
)
|
|
421
421
|
|
|
422
422
|
async def get_twin_by_id(self, twin_id: str) -> Optional[dict[str, Any]]:
|
|
423
423
|
"""Get twin data by ID.
|
{phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/twin_messaging.py
RENAMED
|
@@ -12,6 +12,7 @@ API Design:
|
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
14
|
import asyncio
|
|
15
|
+
import re
|
|
15
16
|
import time
|
|
16
17
|
import random
|
|
17
18
|
import string
|
|
@@ -23,6 +24,15 @@ from phystack.hub_client.types.twin_types import TwinMessageResult, TwinMessageR
|
|
|
23
24
|
|
|
24
25
|
REQUEST_TIMEOUT = 10.0 # seconds
|
|
25
26
|
|
|
27
|
+
# Backward compatibility: strip known type prefixes to extract bare event type.
|
|
28
|
+
# Matches Node.js hub-client behavior for cross-approach communication.
|
|
29
|
+
_KNOWN_PREFIX_PATTERN = re.compile(r"^(edgeInstance|peripheralInstance:[^:]+):")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _strip_type_prefix(message_type: str) -> str:
|
|
33
|
+
"""Strip known type prefix to get bare event type (matches Node.js)."""
|
|
34
|
+
return _KNOWN_PREFIX_PATTERN.sub("", message_type)
|
|
35
|
+
|
|
26
36
|
|
|
27
37
|
@dataclass
|
|
28
38
|
class PendingRequest:
|
|
@@ -177,7 +187,7 @@ class TwinMessaging:
|
|
|
177
187
|
|
|
178
188
|
def handle_response(payload: dict[str, Any]) -> None:
|
|
179
189
|
message_type = (payload.get("data") or {}).get("type") or payload.get("type")
|
|
180
|
-
if message_type ==
|
|
190
|
+
if _strip_type_prefix(message_type) == "response":
|
|
181
191
|
response_data = (payload.get("data") or {}).get("data") or payload.get("data")
|
|
182
192
|
request_id = (response_data or {}).get("requestId")
|
|
183
193
|
|
|
@@ -220,12 +230,10 @@ class TwinMessaging:
|
|
|
220
230
|
event_type: Type of event to listen for.
|
|
221
231
|
callback: Handler function (data, respond?) => None
|
|
222
232
|
"""
|
|
223
|
-
expected_type = f"{self._context.type_prefix}:{event_type}"
|
|
224
|
-
|
|
225
233
|
def handler(payload: dict[str, Any]) -> None:
|
|
226
234
|
message_type = (payload.get("data") or {}).get("type") or payload.get("type")
|
|
227
235
|
|
|
228
|
-
if message_type ==
|
|
236
|
+
if _strip_type_prefix(message_type) == event_type:
|
|
229
237
|
message_data = (payload.get("data") or {}).get("data") or payload.get("data")
|
|
230
238
|
request_id = (message_data or {}).get("requestId") if message_data else None
|
|
231
239
|
source_twin_id = payload.get("sourceTwinId")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/services/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/services/signals.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/twin_registry.py
RENAMED
|
File without changes
|
{phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/types/__init__.py
RENAMED
|
File without changes
|
{phystack_hub_client-0.2.3 → phystack_hub_client-0.2.4}/src/phystack/hub_client/types/twin_types.py
RENAMED
|
File without changes
|
|
File without changes
|