@lucets/client

0.1.0 • Public • Published

@lucets/client

Browser client for @lucets/luce, a versatile WebSocket framework for node.js.

Install

npm i @lucets/client

Browserify

Use in combination with Browserify.

Example

This example shows how to add message hooks and connect to the server.

'use strict'

import Application from './index'

const app = new Application()

app.useMessage(async (message, ctx, next) => {
  console.log(`[message]: ${JSON.stringify(message)}`)
  return next()
})

app.connect('ws://localhost:3003').then(ctx => {
  console.log(`[open]: connected to ${ctx.url.toString()}`)

  let interval: any = setInterval(() => {
    ctx.send({ cmd: 'ping' })
  }, 2500)

  app.once('disconnect', () => clearInterval(interval))
}).catch((err: Error) => {
  console.error('error', err)
})

License

Copyright 2021 Michiel van der Velde.

This software is licensed under the MIT License.

Readme

Keywords

Package Sidebar

Install

npm i @lucets/client

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

7.68 kB

Total Files

5

Last publish

Collaborators

  • michielvdvelde