# linda-socket.io

> Linda implementation on Socket.IO

Latest version **0.2.2** (published 2014-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install linda-socket.io
pnpm add linda-socket.io
yarn add linda-socket.io
bun add linda-socket.io
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2014-10-11 |
| First published | 2013-12-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Sho Hashimoto |
| Maintainers | shokai |
| Keywords | linda, socket.io |

## Links

- npm: https://www.npmjs.com/package/linda-socket.io
- Repository: https://github.com/node-linda/linda-socket.io
- Issues: https://github.com/node-linda/linda-socket.io/issues
- npm.io page: https://npm.io/package/linda-socket.io

## Dependencies (4)

- [debug](https://npm.io/package/debug.md) ~0.7.4
- [socket.io](https://npm.io/package/socket.io.md) *
- [eventemitter2](https://npm.io/package/eventemitter2.md) ~0.4.13
- [socket.io-client](https://npm.io/package/socket.io-client.md) *

## 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

- 0.2.2 (latest) — 2014-10-11
- 0.2.0 — 2014-01-22
- 0.1.7 — 2014-01-22
- 0.1.6 — 2014-01-22
- 0.1.5 — 2014-01-12
- 0.1.4 — 2014-01-12
- 0.1.3 — 2014-01-11
- 0.1.2 — 2014-01-08
- 0.1.1 — 2014-01-08
- 0.1.0 — 2014-01-06
- 0.0.9 — 2014-01-06
- 0.0.8 — 2014-01-06
- 0.0.7 — 2014-01-01
- 0.0.6 — 2013-12-31
- 0.0.5 — 2013-12-31
- … 3 more at https://npm.io/package/linda-socket.io/versions

## README

# Deprecated

move to [linda](https://www.npmjs.org/package/linda)


Linda Socket.IO
===============
<a href="http://en.wikipedia.org/wiki/Linda_(coordination_language)">Coordinatioin Launguage "Linda"</a> implementation for Node.js and Socket.IO

- https://github.com/node-linda/linda-socket.io
- https://npmjs.org/package/linda-socket.io

[![Travis CI Status Badge](https://travis-ci.org/node-linda/linda-socket.io.png)](https://travis-ci.org/node-linda/linda-socket.io)


Install
-------

    % npm install linda-socket.io
    % npm install socket.io socket.io-client


Requirements
------------
- Node.js
- [Socket.IO](http://socket.io/)


Linda
-----
Linda is a coordination launguage for parallel programming.

* http://en.wikipedia.org/wiki/Linda_(coordination_language)
* http://ja.wikipedia.org/wiki/Linda


### TupleSpace
Shared memory on Node.js server.


### Tuple Operations
- write( tuple , options )
  - put a Tuple into the TupleSpace
  - options = {expire : 300}  # => expire after 300 sec
- take( tuple, callback(err, tuple) )
  - get a matched Tuple from the TupleSpace and delete
- read( tuple, callback(err, tuple) )
  - get a matched Tuple from the TupleSpace
- watch( tuple, callback(err, tuple) )
  - overwatch written Tuples in the TupleSpace


Samples
-------

- https://github.com/node-linda/linda-socket.io/tree/master/samples
- https://github.com/node-linda/linda-job-queue-sample

## Install Dependencies

    % git clone https://github.com/node-linda/linda-socket.io.git
    % cd linda-socket.io
    % npm install
    % npm install -g grunt-cli coffee-script


### Chat

    % coffee samples/chat/server.coffee 3000

=> http://localhost:3000


### Job-Queue

    % coffee samples/job-queue/server.coffee 3000

=> http://localhost:3000


### print Tuple read/write/take/watch/cancel logs

    % DEBUG=linda* coffee samples/chat/server.coffee 3000
    % DEBUG=linda* coffee samples/job-queue/server.coffee 3000

Usage
-----

### Setup

Server Side (node.js)

```javascript
var http = require('http');

var app_handler = function(req, res){
  // your web app code
};

var app = http.createServer(app_handler);

var io = require('socket.io').listen(app);

var linda = require('linda-socket.io').Linda.listen({io: io, server: app});

app.listen(3000);
console.log("server start - http://localhost:3000");
```


Client Side (web browser)

```html
<script src="/socket.io/socket.io.js"></script>
<script src="/linda/linda-socket.io.js"></script>
```

```javascript
var socket = io.connect(location.protocol+"//"+location.host);
var linda = new Linda().connect(socket);
```

Client Side (node.js)

```javascript
var LindaClient = require('linda-socket.io').Client;
var socket = require('socket.io-client').connect('http://localhost:3000');
var linda = new LindaClient().connect(socket);
```


### Job-Queue Sample

job client

```javascript
// connect to tuplespace (shared memory)
var ts = linda.tuplespace("calc");

// request
$("#btn_request").click(function(){
  ts.write({type: "request", query: "1-2+3*4"});
});

// wait result
socket.on('connect', function(){
  // overwatch Tuple
  ts.watch({type: 'result'}, function(err, tuple){
    if(err) return;
    console.log(tuple.data.result); // => "1-2+3*4 = 11"
  });
});
```


job worker
```javascript
// connect to tuplespace (shared memory)
var ts = linda.tuplespace("calc");

// calculate
var work = function(){
  ts.take({type: 'request'}, function(err, tuple){
    if(!err){
      var result = eval(tuple.data.query); // => "1-2+3*4"
      console.log(tuple.data.query+" = "+result); // => "1-2+3*4 = 11"
      ts.write({type: 'result', result: result}); // return to 'client' side
    }
    work(); // recursive call
  });
};

socket.on('connect', function(){ // Socket.IO's "connect" event
  work();
});
```

see more [samples](https://github.com/node-linda/linda-socket.io/tree/master/samples)


Test
----

    % npm install
    % npm install -g grunt-cli coffee-script
    % grunt test

watch

    % grunt



Contributing
------------
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

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