Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ _testmain.go

*.orig
examples/benchmark/benchmark
local/
examples/wasm/assets/example.wasm
examples/wasm/assets/example.wasm.gz
examples/wasm/assets/example.wasm.br
local/
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,7 @@ func (c *Client) sendConnect(fn func(*protocol.ConnectResult, error)) error {
req.Name = c.config.Name
req.Version = c.config.Version
req.Data = c.data
req.Headers = c.config.EmulatedHeaders

if len(c.serverSubs) > 0 {
subs := make(map[string]*protocol.SubscribeRequest)
Expand Down
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type Config struct {
CookieJar http.CookieJar
// Header specifies custom HTTP Header to send in WebSocket Upgrade request.
Header http.Header
// EmulatedHeaders to use instead of native Upgrade Header. Can be helpful for WASM context.
EmulatedHeaders map[string]string
// Name allows setting client name. You should only use a limited
// amount of client names throughout your applications – i.e. don't
// make it unique per user for example, this name semantically represents
Expand Down
15 changes: 15 additions & 0 deletions examples/wasm/assets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<meta charset="utf-8"/>
<script src="wasm_exec.js"></script>
<script>
const go = new Go();
WebAssembly.instantiateStreaming(fetch("example.wasm"), go.importObject).then((result) => {
go.run(result.instance);
});
</script>
</head>
<body>
Open DevTools and see console output.
</body>
</html>
Loading
Loading