SignalingClient¶
pybticino.signaling.SignalingClient ¶
Handles the WebRTC signaling WebSocket for BTicino devices.
This client connects to the Netatmo signaling endpoint, subscribes using the "app_security" app type, and provides methods to send/receive WebRTC signaling messages (offer, answer, ICE candidates, terminate).
is_connected
property
¶
Return True if the signaling WS is connected and subscribed.
__init__ ¶
__init__(auth_handler: AuthHandler, on_answer: OnAnswerCallback | None = None, on_candidate: OnCandidateCallback | None = None, on_event: OnEventCallback | None = None) -> None
Initialize the signaling client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth_handler
|
AuthHandler
|
An authenticated AuthHandler instance. |
required |
on_answer
|
OnAnswerCallback | None
|
Async callback invoked when an answer SDP is received. Called with (session_id, sdp). |
None
|
on_candidate
|
OnCandidateCallback | None
|
Async callback invoked when an ICE candidate is received. Called with (session_id, ice_candidate_dict). |
None
|
on_event
|
OnEventCallback | None
|
Async callback for other signaling events (rescind, terminate). Called with (session_id, event_type, full_data). |
None
|
resubscribe
async
¶
Re-subscribe on the existing connection with a fresh token.
Sends a new subscribe message with a refreshed OAuth token on the current WebSocket connection, keeping the session alive without disconnecting. Mirrors WebsocketClient.resubscribe().
ensure_connected
async
¶
Ensure the signaling WS is connected, reconnecting if needed.
send_offer
async
¶
Send an SDP offer to initiate a call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_id
|
str
|
The bridge MAC address. |
required |
sdp
|
str
|
The SDP offer string from the local PeerConnection. |
required |
module_id
|
str | None
|
Optional module ID (external unit) to call. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The session_id assigned by the server. |
Raises:
| Type | Description |
|---|---|
PyBticinoException
|
If the offer fails or times out. |
send_answer
async
¶
Send an SDP answer (for incoming calls).
Uses the session state (session_id, tag_id, device_id, correlation_id) set by the most recent offer or ack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sdp
|
str
|
The SDP answer string. |
required |
send_candidate
async
¶
Send an ICE candidate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidate
|
str
|
The ICE candidate string. |
required |
sdp_m_line_index
|
int
|
The m-line index for the candidate. |
required |
set_session_from_push ¶
Set session state from a push WS offer (incoming call).
When a call comes in via the push WS, the session details are in the push event. This method sets them so send_answer/send_candidate can be used without first sending an offer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
str
|
From extra_params.session_id in the push event. |
required |
tag_id
|
str
|
From extra_params.tag_id in the push event. |
required |
correlation_id
|
str
|
From extra_params.correlation_id in the push event. |
required |
device_id
|
str
|
The bridge MAC (extra_params.device_id). |
required |