New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@yomo/presencejs

Package Overview
Dependencies
Maintainers
4
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yomo/presencejs

YoMo browser sdk

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-14.29%
Maintainers
4
Weekly downloads
 
Created
Source

Quickstart Guide

1.Add the YoMo Client Library SDK

Using npm

$ npm i --save @yomo/presencejs

For CDN, you can use skypack: https://cdn.skypack.dev/@yomo/presencejs

<script type="module">
    import { YoMoClient } from 'https://cdn.skypack.dev/@yomo/presencejs';
</script>
2.Connect to YoMo
import { YoMoClient } from '@yomo/presencejs';

// create an instance.
const yomoclient = new YoMoClient('ws://localhost:3000', {
    reconnectInterval: 5000, // The reconnection interval value.
    reconnectAttempts: 3, // The reconnection attempts value.
});

yomoclient.on('connected', () => {
    console.log('Connected to YoMo');
});
3.Subscribe to messages from the server
yomoclient.on('connected', () => {
    // get a room
    const verse = yomoclient.getVerse('001');

    verse.fromServer('online').subscribe(data => {
        console.log('online:', data);
    });

    verse.fromServer('mousemove').subscribe(data => {
        console.log('mousemove:', data);
    });
});
4.Sending messages to the server
import { map, throttleTime } from 'rxjs/operators';

yomoclient.on('connected', () => {
    const verse = yomoclient.getVerse('001');

    verse.publish('online', {
        id: 'ID',
        x: 10,
        y: 10,
    });

    const mousemove$ = verse.fromEvent(document, 'mousemove').pipe(
        throttleTime(200),
        map(event => {
            return {
                id: 'ID',
                x: event.clientX,
                y: event.clientY,
            };
        })
    );

    verse.bindServer(mousemove$, 'mousemove');
});
5.Close a connection to YoMo
yomoclient.close();
yomoclient.on('closed', () => {
    console.log('Closed the connection to YoMo.');
});

LICENSE

License: MIT

Keywords

FAQs

Package last updated on 14 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc