Skip to main content

Go SDK quickstart

This path builds an application-role WebSocket endpoint. Install the Go SDK:

What this quickstart owns

The endpoint owns the application role. A voice peer connects to it, initializes one call, and exchanges control plus duplex audio for the lifetime of that session.

go get github.com/babelforce/rtvbp/sdk/go@v0.1.1

An application must answer ping, negotiate audio in session.initialize, and acknowledge the terminal session.terminate request. The SDK generates those typed payloads and dispatch adapters from the protocol catalog.

handler := rtvbp.NewHandler(
rtvbp.HandlerConfig{},
v1bridge.NewPingHandler(),
rtvbp.HandleRequest(application.SessionInitialize),
rtvbp.HandleTerminalRequest(application.SessionTerminate),
)

server := ws.NewServer(ws.ServerConfig{
Addr: "0.0.0.0:8080",
Path: "/rtvbp",
}, handler)

The complete compile-tested quickstart selects the deployed L16/8 kHz codec, opens the session audio stream, discards inbound audio, and shuts down cleanly. Replace the discard loop with your own duplex audio pipeline.

Connect it​

  1. Expose the endpoint over TLS as wss://…/rtvbp.
  2. Configure authentication before accepting the WebSocket upgrade. For babelforce Cloud, follow the deployment JWT guide.
  3. Leave the default WebSocket profile as rtvbp.v1 unless both peers support another profile.
  4. Implement the events and operations your application uses from the generated application role.

The WebSocket binding defines framing and close behavior. The generated initialization flow shows the first control exchange.

Optional WebRTC audio​

WebRTC is an additional binding, not a replacement for the setup above. A server can offer both, and each client chooses plain WebSocket binary audio (rtvbp.v1) or Pion WebRTC audio (rtvbp.webrtc.v1) at connection setup. See the WebRTC + WebSocket guide and its compile-tested dual-binding example.