Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
37 lines
1.3 KiB
Markdown
37 lines
1.3 KiB
Markdown
# @mygo-plugins/websocket
|
|
|
|
A `WebSocket` for [MyGo](https://github.com/egoist/mygo) apps whose
|
|
connections Go makes, with the API of the browser's. Unlike the browser's,
|
|
it may send any header with the opening handshake, such as Authorization,
|
|
Cookie or Origin, and is not subject to the page's Content Security Policy.
|
|
|
|
Use the plugin in Go:
|
|
|
|
```go
|
|
import "github.com/egoist/mygo/plugins/websocket"
|
|
|
|
mygo.Use(websocket.Plugin) // or websocket.New(websocket.Options{...})
|
|
```
|
|
|
|
and connect in the frontend:
|
|
|
|
```ts
|
|
import { WebSocket } from "@mygo-plugins/websocket";
|
|
|
|
const ws = new WebSocket("wss://example.com/live", ["v1"], {
|
|
headers: { authorization: `Bearer ${token}` },
|
|
});
|
|
ws.onopen = () => ws.send("hello");
|
|
ws.onmessage = (e) => console.log(e.data);
|
|
ws.onclose = (e) => console.log(e.code, e.reason, e.wasClean);
|
|
```
|
|
|
|
Messages are sent in order, `bufferedAmount` counts the bytes Go has not
|
|
written yet, and received messages wait in Go while the page is behind, so a
|
|
fast server cannot fill the page's memory. Connections close (1001, going
|
|
away) when their page navigates away or its window closes. No extensions
|
|
(such as permessage-deflate) are negotiated.
|
|
|
|
[The documentation](https://github.com/egoist/mygo/blob/main/docs/plugins/websocket.md)
|
|
covers closing, failures and the options of the Go side.
|