Skip to content

Conversation

EastSun5566
Copy link
Contributor

@EastSun5566 EastSun5566 commented Jan 22, 2025

Description

Add the ability to disable awareness functionality on both client and server side. Default is enabled.

Usage

Client-side:

const provider = new SocketIOProvider(url, roomName, doc, {
  enableAwareness: false
})

Server-side:

const server = await registerYSocketIOServer(io, store, {
  ...otherOptions,
  enableAwareness: false 
})

@EastSun5566 EastSun5566 self-assigned this Jan 22, 2025
@EastSun5566 EastSun5566 marked this pull request as ready for review January 22, 2025 15:38
@galaxian85 galaxian85 force-pushed the feat/add-enable-awareness-options branch from b20e1bc to a13c93e Compare January 23, 2025 06:53
@galaxian85
Copy link
Collaborator

@EastSun5566 請假,我幫他解 conflict

@stanley2058
Copy link
Collaborator

There's a TSC error:

src/y-socket-io/y-socket-io.js:475:50 - error TS2345: Argument of type 'Awareness | null' is not assignable to parameter of type 'Awareness'.
  Type 'null' is not assignable to type 'Awareness'.

475           AwarenessProtocol.applyAwarenessUpdate(existDoc.awareness, msg, null)
                                                     ~~~~~~~~~~~~~~~~~~


Found 1 error in src/y-socket-io/y-socket-io.js:475

for (const msg of awareness) {
if (msg.length === 0) continue
AwarenessProtocol.applyAwarenessUpdate(existDoc.awareness, msg, null)
}

Should be:

        if (existDoc.awareness) {
          for (const msg of awareness) {
            if (msg.length === 0) continue
            AwarenessProtocol.applyAwarenessUpdate(existDoc.awareness, msg, null)
          }
        }

@Yukaii Yukaii merged commit ff91ee6 into main Jan 23, 2025
1 check passed
@Yukaii Yukaii deleted the feat/add-enable-awareness-options branch January 23, 2025 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants