Gathering detailed insights and metrics for y-protocols-node14
Gathering detailed insights and metrics for y-protocols-node14
Gathering detailed insights and metrics for y-protocols-node14
Gathering detailed insights and metrics for y-protocols-node14
npm install y-protocols-node14
Typescript
Module System
Node Version
NPM Version
76.3
Supply Chain
92.4
Quality
75.5
Maintenance
100
Vulnerability
100
License
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
-60%
2
Compared to previous week
Last Month
-27.8%
13
Compared to previous month
Last Year
32.3%
123
Compared to previous year
1
1
Binary encoding protocols for syncing, awareness, and history information
This API is unstable and subject to change.
1import * as awarenessProtocol from 'y-protocols/awareness.js'
The Awareness protocol implements a simple network agnostic algorithm that manages user status (who is online?) and propagate awareness information like cursor location, username, or email address. Each client can update its own local state and listen to state changes of remote clients.
Each client has an awareness state. Remote awareness are stored in a Map that maps from remote client id to remote awareness state. An awareness state is an increasing clock attached to a schemaless json object.
Whenever the client changes its local state, it increases the clock and
propagates its own awareness state to all peers. When a client receives a remote
awareness state, and overwrites the clients state if the received state is newer
than the local awareness state for that client. If the state is null
, the
client is marked as offline. If a client doesn't receive updates from a remote
peer for 30 seconds, it marks the remote client as offline. Hence each client
must broadcast its own awareness state in a regular interval to make sure that
remote clients don't mark it as offline.
1const awareness = new awarenessProtocol.Awareness()
clientID:number
getLocalState():Object<string,any>|null
setLocalState(Object<string,any>|null)
setLocalStateField(string, any)
getStates():Map<number,Object<string,any>>
on('change', ({ added: Array<number>, updated: Array<number>
removed: Array<number> }, [transactionOrigin:any]) => ..)
on('update', ({ added: Array<number>, updated: Array<number>
removed: Array<number> }, [transactionOrigin:any]) => ..)
The MIT License © Kevin Jahns
No vulnerabilities found.
No security vulnerabilities found.