Signature: websocketConnect(url: String, messageHandler: (String) -> Result<Success, String>) -> Result<WebSocketID, String>

Description: Establishes a WebSocket connection with a message handler callback. (Implementation note: currently returns an integer status code; the Result-typed API shown in the signature is planned.)

Parameters

Returns: Result<WebSocketID, String>

Example

fn handleMessage(message: String) -> ResultSuccess, String> = {
    print("Received: ${message}")
    Success()
}
let wsResult = websocketConnect(url: "ws://localhost:8080/chat", messageHandler: handleMessage)
match wsResult {
    Success wsId => print("Connected with ID: ${wsId}")
    Err message => print("Failed to connect: ${message}")
}