Back to Wails

🚀 WebSocket Transport Example

v3/examples/websocket-transport/assets/index.html

2.13.01.2 KB
Original Source

🚀 WebSocket Transport Example

Custom IPC transport using WebSockets instead of HTTP fetch

Connection Status

Disconnected

â„šī¸ Transport Info: This example uses a custom WebSocket transport running on ws://localhost:9099/wails/ws instead of the default HTTP fetch-based transport. All Wails generated bindings work identically!

The methods below use GreetService.Greet(), GreetService.Echo(), etc. from the generated bindings, proving that custom transports work seamlessly with Wails code generation.

🕐 Server Timer (Auto-updating via Events)

Waiting for timer...

✨ Automatic Event Forwarding: The server emits a timer:tick event every second. Because the WebSocket transport implements EventTransport, these events are automatically forwarded to the frontend with zero manual wiring code!

Test Dialog

Open

Click "Open" to test the binding...

Test Greet Method (with Events)

Greet

Click "Greet" to test the binding...

📡 Event Counter: 0 (Updates via WebSocket events)

Test Echo Method

Echo

Click "Echo" to test...

Test Add Method

Add

Click "Add" to calculate...

Test GetTime Method

Get Server Time Click to get current server time...