HandshakeHandler¶
veltix.handler.handshake_handler.HandshakeHandler
¶
Handles the HELLO / HELLO_ACK exchange for a single connection.
SERVER side
- prepare_hello() — creates HELLO request (call before register()!)
- send_hello() — sends the prepared HELLO
- handle_hello_ack() — validates the HELLO_ACK
CLIENT side
- handle_hello() — receives and validates the HELLO
- send_hello_ack() — sends HELLO_ACK back to the server
__init__
¶
Initialize the handshake handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sender
|
Sender
|
Sender instance for outgoing messages |
required |
mode
|
Mode
|
Mode.SERVER or Mode.CLIENT |
required |
prepare_hello
¶
SERVER: Prepare a HELLO request without sending it.
Must be called BEFORE register() and send_hello() to avoid the race condition where HELLO_ACK arrives before the queue is registered.
Returns:
| Type | Description |
|---|---|
tuple[str, Request]
|
(request_id, hello_request) — register request_id, then call send_hello() |
send_hello
¶
SERVER: Send a previously prepared HELLO request.
Must be called AFTER register() to avoid race conditions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hello
|
Request
|
The Request object returned by prepare_hello() |
required |
client_conn
|
Raw socket of the target client (server mode only) |
None
|
handle_hello_ack
¶
SERVER: Validate an incoming HELLO_ACK from the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Response
|
Incoming HELLO_ACK Response object |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if handshake accepted, False otherwise |
handle_hello
¶
CLIENT: Validate an incoming HELLO from the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Response
|
Incoming HELLO Response object |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if HELLO is valid, False otherwise |
send_hello_ack
¶
CLIENT: Send HELLO_ACK back to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_id
|
str
|
The request_id from the received HELLO — used for correlation |
required |