Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into foxgis
Browse files Browse the repository at this point in the history
  • Loading branch information
jingsam committed Aug 26, 2024
2 parents 6dc5a82 + 90ed06b commit 1b3df30
Showing 1 changed file with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,28 @@ const MOUSE_EVENT = 'cursor'
// Subscribe to mouse events.
// Our second parameter filters only for mouse events.
channel
.on(
'broadcast',
{ event: MOUSE_EVENT },
(event) => { receivedCursorPosition(event) }
)
.subscribe()
.on('broadcast', { event: MOUSE_EVENT }, (event) => {
receivedCursorPosition(event)
})
.subscribe()

// Handle a mouse event.
const receivedCursorPosition({ event, payload }) => {
console.log(`
const receivedCursorPosition = ({ event, payload }) => {
console.log(`
User: ${payload.userId}
x Position: ${payload.x}
y Position: ${payload.y}
`)
}

// Helper function for sending our own mouse position.
const sendMousePosition(channel, userId, x, y) => {
return channel.send({
type: 'broadcast',
event: MOUSE_EVENT,
payload: { userId, x, y }
})
const sendMousePosition = (channel, userId, x, y) => {
return channel.send({
type: 'broadcast',
event: MOUSE_EVENT,
payload: { userId, x, y },
})
}

```

### Presence Example
Expand Down

0 comments on commit 1b3df30

Please sign in to comment.