diff --git a/README.md b/README.md index cc73a88..239ef17 100755 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ module.exports = { port: 1080, servers: [{ enabled: true, + transport: 'tcp', host: "bs.example.com", port: 6858, key: "j+b3)I NOTE: `server*` are used on the server side while `client*` are used on the client side. Every method gets an object which contains three parameters you need: -| PARAM | DESCRIPTION | -| :-------- | :------------------------------------------------------------------------- | -| buffer | output from the previous middleware | -| next | call it with a new buffer once **async** process done | -| broadcast | call it with an action to notify other middlewares | -| fail | call it once handshake failed, connection will be closed in random seconds | +| PARAM | DESCRIPTION | +| :------------------------ | :------------------------------------------------------------------------- | +| buffer | output from the previous preset | +| next(buffer) | asynchronously process buffer to the next preset | +| broadcast(action) | broadcast an action to other middlewares | +| direct(buffer, isReverse) | ignore the following presets, send data directly to fsocket or bsocket | +| fail(message) | report that the preset is fail to process | ### Presets Decoupling @@ -175,7 +180,7 @@ Action is a plain object which only requires a `type` field: // action { type: , - payload: + ... } ``` @@ -183,6 +188,8 @@ Once broadcast, **all** other middlewares will receive the action in **onNotifie ```js // custom.js +import {IPreset} from './defs'; + export default class CustomPreset extends IPreset { /** @@ -206,13 +213,15 @@ There are two hooks available: ```js // custom.js +import {IPreset} from './defs'; + export default class CustomPreset extends IPreset { - beforeOut({buffer/* , next, broadcast, fail */}) { + beforeOut({buffer/* , next, broadcast, direct, fail */}) { return buffer; } - beforeIn({buffer/* , next, broadcast, fail */}) { + beforeIn({buffer/* , next, broadcast, direct, fail */}) { return buffer; } @@ -231,6 +240,8 @@ export default class CustomPreset extends IPreset { You can access user configuration from your preset: ```js +import {IPreset} from './defs'; + export default class CustomPreset extends IPreset { constructor() {