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

connect.io

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect.io

chrome.runtime.connect wrapper that using Stock.IO API.

  • 0.1.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

connect.io

Real-time bidirectional event-based communication in Chrome extensions or Apps inspired by Socket.IO.

Install

npm i -S connect.io

Usage

Client(content-scripts.html):

<script src="node_modules/connect.io/dist/connect.js"></script>
<script>
const client = new ChromeConnect.Client('optional extensions or apps id or tabId, default value is chrome.runtime.id');
client.on('welcome',(msg) => {
  console.log(msg); // 'hello world'
});

// get message acknowledgements
client.send('report clients number', (number, error) => {

  // When connection has been disconnected until get response, then error will be a string.
  // It's often happened when you connect to a tab from extension but you don't have permission. (etc chrome:// 、chrome-extension://)
  if( error ) {
    throw new Error(error);
  }

  console.log(number); // 100
});
</script>

background.html:

<script src="node_modules/connect.io/dist/connect.js"></script>
<script>
const server = new ChromeConnect.Server();
server.on('connect',(client)=> {

  if (client.exteranl && client.port.sender.url === blackList) {
    client.disconnect();
    return;
  }

  // Only send message to this connection client.
  client.send('welcome','hello world');

  // Sending a message to everyone else except for the connection that starts it.
  client.broadcast('join','new client joined.');

  // Sending acknowledgements
  client.on('report clients number', (data, sendResponse) => {
    console.log(data); // when no data send to server, the data argument will be undefined
    sendResponse(100);
  });

  client.on('disconect', () => {
    // Sending messge to every connection.
    server.send('Someone out');
  });

});
</script>

FAQs

Package last updated on 17 Dec 2015

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