einaros/sse.js — pull request #7 by trygve-lie (2012-11-05 17:10:32+00:00)
Title: Added support for retry

The [SSE spec has a retry method](http://dev.w3.org/html5/eventsource/#event-stream-interpretation) that makes it possible to adjust how often a client should try to re-connect to the server if the client disconnects.

This can be set for each message that is sent and the client will use the last set value when the client goes offline.

Due to the fact that this is set on each message it could potentially introduce a new function attribute on the client send method like this:

```js
client.send(event, data, id, retry);
```

Event, id and retry is not mandatory in a Event so the respective attributes are therefor not mandatory in the client method. Having all these none mandatory attributes would make it kinda messy to handle the different scenarios where one attributes is provided and not another. Do deal with this I have added support for providing _one_ object with the different values to the send method instead of letting the send method have four attributes.

In other words; one can now do the following:

```js
client.send({event : 'foo', data : 'bar', id : 1, retry : 10000});
```

Or if one just want too set the retry:

```js
client.send({data : 'bar', retry : 10000});
```

The send method are still able to receive values on event, data and id attributes as before too not break existing implementations. Retry is not added to this, it is only added to the object one can pass. If the first attribute to the send method is an object the data and id attribute will be ignored.