buildYjsAwareness builds a minimal awareness message. Format: messageAwareness(1) + clientId + clock + var1 + var2 + json_string(payload-prefixed)
(clientId uint64)
| 78 | // buildYjsAwareness builds a minimal awareness message. |
| 79 | // Format: messageAwareness(1) + clientId + clock + var1 + var2 + json_string(payload-prefixed) |
| 80 | func 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. |
| 93 | func tryReadYJSMessage(conn *gorillaWs.Conn, timeout time.Duration) ([]byte, bool) { |
no test coverage detected