Documentation
¶
Overview ¶
Command duplex is the bidirectional stream example: an embedded page talks to Go services over ipc streams that carry JSON and bytes both ways.
- Echo: the page sends JSON and bytes, Go writes each frame back (Router.HandleDuplex, Stream.Receive / Write / WriteBytes).
- Upload: file.stream().pipeTo(stream.writable); Go writes the bytes to a temporary file as they arrive and reports progress on the same stream.
- Terminal: a local shell (Go "Term", os/exec pipes through Stream.ReadWriter) driven by the page's stream.readable/writable.
- Go panel (-panel): a Go-drawn card over the page that uses the same Echo service in process (Router.Open), next to the page's own.
- Benchmark: 64 B echo latency (p50/p99) and 64 KiB throughput in both directions, printed as one JSON line.
Run it with:
go run ./examples/duplex # interactive go run ./examples/duplex -panel # with the Go-drawn Echo panel go run ./examples/duplex -bench # runs the benchmark, prints JSON, quits
-page NAME loads another page of frontend/ instead of index.html, e.g. probe.html, the WebKit streaming probe of internal/platform/darwin's TestStreamingDeliveryProbe (needs TANGO_SCHEME_PROBE=1 and, on macOS, a development build: -tags tango_dev, which automation adds), or csp.html, the app's page under a CSP that blocks fetch to the asset origin (TestLaneCSPBlocked; a test route, needs TANGO_SCHEME_PROBE=1).
TANGO_SCHEME_PROBE=1 also adds the test routes (/__test/...) and the "Debug.Stats" ipc method of package services, used by the scheme handler and lane tests of internal/platform/darwin. On macOS the backend's own counters in Debug.Stats (and the bench's upMain) and TANGO_IPC_LANES_DARWIN=all need a development build too (go run -tags tango_dev ./examples/duplex); a plain build reports the counters as zero and treats =all like the default. frontend/iframe.html is a same-origin subframe page for TestLaneSubframeAccess.
With -tags tango_selftest or tango_dev, TANGO_SCHEME_SELFTEST=1 runs the desktop lane self-test, prints one selftest result and quits.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package services holds the ipc services shared by the duplex examples (examples/duplex on the desktop, examples/duplex-mobile on iOS).
|
Package services holds the ipc services shared by the duplex examples (examples/duplex on the desktop, examples/duplex-mobile on iOS). |