all repos — underbbs @ 89df01f089e2e00fa6fbcc5fa147074cce4e81a2

decentralized social media client

hack to make subprotocol work
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQT/foVVmI9pK13hPWFohAcXSWbK8wUCZkpneQAKCRBohAcXSWbK
8w6xAQDXW1/9HyXx0j5q56e2UgfNCcMC8PGI+jEyeGbt8LzwJwD/fzYUgPTxZLqB
eL99t0424Zea/6qBgZCILubAmjZzkgQ=
=3mvB
-----END PGP SIGNATURE-----
commit

89df01f089e2e00fa6fbcc5fa147074cce4e81a2

parent

529c031c41c76b307bfbc3725a88544479b51dc1

2 files changed, 11 insertions(+), 1 deletions(-)

jump to
M server/server.goserver/server.go

@@ -13,6 +13,7 @@ "io/ioutil"

"log" "net/http" "nhooyr.io/websocket" + "strings" "sync" "time" )

@@ -64,6 +65,7 @@ }

// decode subprotocol data into settings objects data := c.Subprotocol() + data = strings.ReplaceAll(data, ".", "=") // base64 decode decoded, err := base64.StdEncoding.DecodeString(data)
M ts/index.tsts/index.ts

@@ -211,11 +211,19 @@ for (let a of settings.adapters) {

subprotocol += JSON.stringify(a) + ","; } subprotocol += "]"; - subprotocol = btoa(subprotocol); + subprotocol = btoa(subprotocol).replace("=", "."); // open the websocket connection with settings as subprotocol const wsProto = location.protocol == "https:" ? "wss" : "ws"; _conn = new WebSocket(`${wsProto}://${location.host}/subscribe`, subprotocol); + _conn.addEventListener("open", (e: any) => { + console.log("websocket connection opened"); + console.log(JSON.stringify(e)); + }); + _conn.addEventListener("error", (e: any) => { + console.log("websocket connection error"); + console.log(JSON.stringify(e)); + }); _("websocket", _conn); } }