apeman-app-sse

apeman app for sse (Server-Sent Events)

"!!NO LONGER_MAINTAINED"
Last updated 4 years ago by okunishinishi .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install apeman-app-sse 
SYNC missed versions from official npm registry.

apeman-app-sse

Build Status Code Climate Code Coverage npm Version JS Standard

apeman app for sse (Server-Sent Events)

Installation

$ npm install apeman-app-sse --save

Usage

  1. Define an app within Apemanfile.js
  2. Call the app via apeman app command.

Apemanfile.js

/** This is an example Apemanfile to use apeman-app-sse */

'use strict'

module.exports = {
  $pkg: { /* ... */ },
  $apps: {
    // Define your own app.
    'my-app-01': {
      // Map url and handlers.
      '/my-sse': [
        require('apeman-app-sse')(
          (client) => {
            client.send({
              event: 'greeting',
              data: 'hi,there'
            })
            client.on('close', () => {
              /* ... */
            })
          },
          {
            // Options
          })
      ]
    }
  }
}

Then,

$ apeman app my-app-01 -p 3000

Client slide script

'use strict'

const EventSource = require('eventsource')

let es = new EventSource('/my-sse')
es.addEventListener('greeting', (e) => {
  console.log(e.data) // -> 'hi,there'
})

Signature

apemanAppSse(handler, options) -> function

apeman app for sse (Server-Sent Events)

Args
Name Type Default Description
handler function SSE Client handler
options object Optional settings.

License

This software is released under the MIT License.

Links

Current Tags

  • 2.0.0                                ...           latest (4 years ago)

5 Versions

  • 2.0.0 [deprecated]           ...           4 years ago
  • 1.2.1 [deprecated]           ...           4 years ago
  • 1.2.0 [deprecated]           ...           4 years ago
  • 1.0.1 [deprecated]           ...           4 years ago
  • 1.0.0 [deprecated]           ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (14)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |