Help us shape the future of Go! Take the 2026 Go Developer Survey

wasmrpc

package
v1.3.104 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package wasmrpc pkg/wasmrpc/bridge.go c3-vis-wasm `skywire cli` clients.

A wasm-visor runs in a browser tab and cannot open a TCP listener, so the connection is inverted: the tab dials the host over a single WebSocket, both ends wrap that one connection as a yamux session, and the HOST opens a fresh yamux stream per local `skywire cli` connection. The tab accepts each stream into its rpc.Server.ServeConn. So:

skywire --rpc 127.0.0.1:<port> visor info   # drives one specific tab

and N tabs => N bridges on N ephemeral ports — driving multiple wasm-visors with the ordinary CLI. The host end is Bridge (this file); the tab end is ServeTab (tab.go), which the wasm-visor calls.

Package wasmrpc pkg/wasmrpc/tab.go c3-vis-wasm

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeTab

func ServeTab(tabConn net.Conn, serve func(stream io.ReadWriteCloser)) error

ServeTab runs the TAB end of the bridge: it wraps tabConn (the tab's WebSocket to the host) in a yamux CLIENT, accepts the streams the host opens (one per `skywire cli` connection), and hands each to serve — typically a closure that calls rpc.Server.ServeConn(stream). It blocks until the session ends (the WS drops or Close is called on the underlying conn), then returns the error.

Pure Go (yamux + net), so it compiles for js/wasm as well as native — the wasm-visor calls it with a net.Conn wrapping a browser WebSocket.

Types

type Bridge

type Bridge struct {
	// contains filtered or unexported fields
}

Bridge fronts ONE tab: a yamux session over the tab's WebSocket connection, plus a local TCP listener whose every accepted connection is piped to a fresh yamux stream (the tab serves net/rpc over it).

func NewBridge

func NewBridge(tabConn net.Conn, port int, log func(string)) (*Bridge, error)

NewBridge wraps tabConn (the host side of the tab's WebSocket, as a net.Conn) in a yamux SERVER and opens a local TCP listener on 127.0.0.1:<port> (port 0 = an OS-assigned ephemeral port). Accepted cli connections are each piped to a new yamux stream. Close tears it all down.

func (*Bridge) Addr

func (b *Bridge) Addr() string

Addr is the local address `skywire cli --rpc` should target for this tab.

func (*Bridge) Close

func (b *Bridge) Close() error

Close shuts the listener and the yamux session (idempotent).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL