# kalm-j

> The socket optimizer

Latest version **1.3.5** (published 2016-08-24) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install kalm-j
pnpm add kalm-j
yarn add kalm-j
bun add kalm-j
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.5 |
| Published | 2016-08-24 |
| First published | 2016-08-24 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | frederic charette |
| Maintainers | joesonw |
| Keywords | socket, tcp, udp, client, server, service, peer, micro-service, low-latency, light, ipc, messaging, queue |

## Links

- npm: https://www.npmjs.com/package/kalm-j
- Repository: https://github.com/joesonw/kalm
- Homepage: https://github.com/joesonw/kalm#readme
- Issues: https://github.com/joesonw/kalm/issues
- npm.io page: https://npm.io/package/kalm-j

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) 2.2.x
- [binary-split](https://npm.io/package/binary-split.md) 1.0.x

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.3.5 (latest) — 2016-08-24
- 1.3.3 — 2016-08-24
- 1.3.2 — 2016-08-24

## README

<img align="left" src="http://i231.photobucket.com/albums/ee109/FeD135/kalm_logo_bolded.png">
# Kalm
*The Socket Optimizer*

[![Kalm](https://img.shields.io/npm/v/kalm.svg)](https://www.npmjs.com/package/kalm)
[![Build Status](https://travis-ci.org/fed135/Kalm.svg?branch=master)](https://travis-ci.org/fed135/Kalm)
[![Dependencies Status](https://david-dm.org/fed135/Kalm.svg)](https://www.npmjs.com/package/kalm)
[![Code Climate](https://codeclimate.com/github/fed135/Kalm/badges/gpa.svg)](https://codeclimate.com/github/fed135/Kalm)
[![Gitter](https://img.shields.io/gitter/room/fed135/kalm.svg)](https://gitter.im/fed135/Kalm)

---

Simplify and optimize your Socket communications with:

- Easy-to-use single syntax for all protocols
- Configurable packet bundling (High-level Naggle's algorithm implementation)
- Multiplexing for all protocols
- Ultra-flexible and extensible, load your own adapters and encoders

---

## Compatibility

 * NODE >= 6.0.0

 * Webpack 1 || 2.1.x


## Performance analysis

**Requests per minute**

<img src="http://i231.photobucket.com/albums/ee109/FeD135/perf_v120.png">

*Benchmarks based on a single-thread queue test with Kalm default bundling settings*

**Bytes transfered**

<img src="http://i231.photobucket.com/albums/ee109/FeD135/transfered_v100.png">

*Number of protocol overhead bytes saved per request*


## Installation

    npm install kalm


## Usage

**Server**

```node
    var Kalm = require('kalm');

    // Create a server, listening for incoming connections
    var server = new Kalm.Server({
      port: 6000,
      adapter: 'udp',
      encoder: 'json',
      channels: {
        messageEvent: function(data) {               // Handler - new connections will register to these events
          console.log('User sent message ' + data.body);
        }
      }
    });

    // When a connection is received, send a message to all connected users
    server.on('connection', function(client) {    // Handler, where client is an instance of Kalm.Client
      server.broadcast('userEvent', 'A new user has connected');  
    });
    
```

**Client**

```node
    // Opens a connection to the server
    var client = new Kalm.Client({
      hostname: '0.0.0.0', // Server's IP
      port: 6000, // Server's port
      adapter: 'udp', // Server's adapter
      encoder: 'json', // Server's encoder
      channels: {
        'userEvent': function(data) {
          console.log('Server: ' + data);
        }
      }
    });

    client.send('messageEvent', {body: 'This is an object!'}); 
    client.subscribe('someOtherEvent', function() {});

```
## Documentation

[API docs](https://fed135.github.io/kalm.github.io)


## Adapters

- ipc (bundled)
- tcp (bundled)
- udp (bundled)
- [kalm-websocket](https://github.com/fed135/kalm-websocket)
- [kalm-webrtc](#) (In-dev) 


## Encoders

- json (bundled)
- [kalm-msgpack](https://github.com/fed135/kalm-msgpack)
- [kalm-snappy](https://github.com/fed135/kalm-snappy)
- [kalm-protocol-buffer](#) (In-dev)


## Loading custom adapters

The framework is flexible enough so that you can load your own custom adapters, encoders or middlewares

```node
    // Custom adapter loading example
    var Kalm = require('kalm');
    var WebRTC = require('kalm-webrtc');
    var msgpack = require('kalm-msgpack');

    Kalm.adapters.register('webrtc', WebRTC);
    Kalm.encoders.register('msg-pack', msgpack);

    var server = new Kalm.Server({
      port: 3000,
      adapter: 'webrtc',
      encoder: 'msg-pack'
    });
```


## Run tests

    npm test


## Logging

Kalm uses [debug](https://github.com/visionmedia/debug)

    export DEBUG=kalm

You can also gather optimization statistics by piping `kalm:stats`

    export DEBUG=kalm:stats myApp.js > stats.log


## Roadmap

[Milestones](https://github.com/fed135/Kalm/milestones)


## Presentations

- [JS Montreal](http://www.meetup.com/js-montreal/events/224538913/) - June 14th 2016

---
_Source: https://npm.io/package/kalm-j · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
