# BH Fifo

UDP server like a Fifo with bh-fifo.

**Note:**
> This server manage only one client.

## How to install

`npm install [--save] bh-fifo`

## BH Fifo dependencies

1. dgram
1. bh-buffer
1. bh-configuration
1. bomo-logger

## Configuration reference

> File settings.json must be added on conf folder on your root project.

```json
{
  "server": {
    "protocol": "udp4"
  },
  "buffer": {
    "length": 1000
  },
  "logger": {
    "transports": [
      {
        "transport": "winston.transports.Console",
        "args": {
          "level": "debug",
          "timestamp": true
        }
      },
      {
        "transport": "winston.transports.File",
        "args": {
          "name": "error-file",
          "filename": "/tmp/error.log",
          "level": "error",
          "timestamp": true
        }
      },
      {
        "transport": "winston.transports.File",
        "args": {
          "name": "frame-file",
          "filename": "/tmp/frame-new.log",
          "level": "info",
          "timestamp": true
        }
      }
    ]
  }
}
```

> Env variables must be present

```bash
export BLACKBOX_FIFO_HOST=xxxx
export MY_FIFO_PORT=xxxx
```

## How to use

```js
'use strict'

var BHFifo = require('bh-fifo');

var bhFifo = new BHFifo('settings.json', 'my');
```

```bash
nc -u host port

{"type": "pusher", "data": {"foo": "bar"}}
{"type": "reader", "data": {}}
{"type": "info", "data" : {}}
{"type":"alive","data":{}}
```
