@rainder/request-response-wrapper
Generic request/response wrapper
Last updated 3 years ago by rainder .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @rainder/request-response-wrapper 
SYNC missed versions from official npm registry.

Generic Request/Response Wrapper

Generic Request/Response wrapper

Example


const RequestResponseWrapper = require('@rainder/request-response-wrapper');

const wrapper = new class extends RequestResponseWrapper {

  //implement a custom logic of writing data to the socket connection
  send(data, connection) {
    return connection.write(data);
  }
  
  // process request and return response
  // .send(response) will be called on the same connection
  onRequest(data) {
    return Promise.resolve('response');
  }
  
  onPush(data) {
    processPush(data);
  }
}

socketServer.on('data', (data, connection) => {
  wrapper.receive(data, connection);
});

See sample.js for example

API

receive(data, ...args): Promise

send(data, ...args): Promise

request(data, ...args): Promise

push(data, ...args): Promise

onPush(data, ...args): void

onRequest(data, ...args): void

Current Tags

  • 0.4.1                                ...           latest (3 years ago)

10 Versions

  • 0.4.1                                ...           3 years ago
  • 0.4.0                                ...           3 years ago
  • 0.3.2                                ...           3 years ago
  • 0.3.1                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.2                                ...           3 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 5
Last Day 0
Last Week 1
Last Month 3
Dependencies (3)
Dev Dependencies (3)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |