MCPcopy
hub / github.com/daptin/daptin / buildYjsAwareness

Function buildYjsAwareness

yjs_test.go:80–90  ·  view source on GitHub ↗

buildYjsAwareness builds a minimal awareness message. Format: messageAwareness(1) + clientId + clock + var1 + var2 + json_string(payload-prefixed)

(clientId uint64)

Source from the content-addressed store, hash-verified

78// buildYjsAwareness builds a minimal awareness message.
79// Format: messageAwareness(1) + clientId + clock + var1 + var2 + json_string(payload-prefixed)
80func buildYjsAwareness(clientId uint64) []byte {
81 buf := &bytes.Buffer{}
82 yjsWriteUvarint(buf, 1) // messageAwareness
83 yjsWriteUvarint(buf, clientId) // clientId
84 yjsWriteUvarint(buf, 1) // clock
85 yjsWriteUvarint(buf, 1) // var1
86 yjsWriteUvarint(buf, 0) // var2
87 jsonStr := `{"user":{"name":"test"}}`
88 yjsWritePayload(buf, []byte(jsonStr))
89 return buf.Bytes()
90}
91
92// tryReadYJSMessage reads a binary message, returning ok=false on timeout/error.
93func tryReadYJSMessage(conn *gorillaWs.Conn, timeout time.Duration) ([]byte, bool) {

Callers 1

TestYJSAwarenessRelayFunction · 0.85

Calls 2

yjsWriteUvarintFunction · 0.85
yjsWritePayloadFunction · 0.85

Tested by

no test coverage detected