/atom-socket

Share websockets in Atom Packages

Primary LanguageJavaScriptMIT LicenseMIT

AtomSocket

Share websockets in Atom Packages.

How It Works

AtomSocket uses Atom's localStorage API (via page-bus) to share websocket connections in Atom packages across render processes.

Install

npm install atom-socket --save

Usage

const AtomSocket = require('atom-socket')

const socket = new AtomSocket('term', 'wss://ide.learn.co:443/terminal')

socket.on('error', (err) => {
  console.error(err)
})

socket.on('open', () => {
  console.log('Client Connected')
})

socket.on('close', () => {
  console.log('Client Closed')
})

socket.on('message', (msg) => {
  console.log(msg)
})

socket.on('open:cached', () => {
  console.log('Client Connected through Existing WebSocket')
})

socket.send('hello world')

socket.close()

socket.reset()

License

MIT Licensed