Giter VIP home page Giter VIP logo

rapport's People

Contributors

lrezek avatar

Stargazers

 avatar

Watchers

 avatar  avatar

rapport's Issues

Add default handlers

In order to add connection retry capabilities, rapport needs to add a default onOpen and onClose handler after executing plugins.

Add connection retry capabilities

We need to add connection retry capabilities to the library, so that when the socket closes it reconnects automatically. This should support several retry strategies.

Add support for automatic heartbeats

Add support for an automatic and configurable heartbeat. The heartbeat message content should be configurable, along with the interval at which they are sent.

Improve dispatch speed by adding handledVerb functionality to standard routes

When going through standard routes, we try the entire chain for a matching route before moving to the regex routes. We can improve this with a handledVerbs property that we update when we add handlers (similar to the regex routes).

Thus, the routes object will look like this:

routes = { '/users': { chain: [], handledVerbs = {} } }

Refactor "Global Handler" to "Middleware"

We should refactor instances of "global handler" with "middleware", to better match the express terminology.

Error handlers should be called "Error handling middleware functions".

onClose without a message throws an error

If a message is omitted when closing a socket, the client receiving the close dies. This is because onClose will call util.parse('','');, and since '' is falsey, that does not count as a default value.

The default value check in 'util.parseshould be changed totypeof defaultValue !== 'undefined'`

Error responses are not stringified

When respond to a request with an error, the error object is not stringified properly. The following test fails:

it('Wraps an error object and sends it', () => {
    wrappedSocket.respondWithError('some ID', new Error('error message'));
    mockSocket.messagesSent.should.equal(1);
    const message = JSON.parse(mockSocket.lastSentMessage);

    message.should.have.a.property('responseId').that.equals('some ID');
    message.should.have.a.property('error').that.is.an('object');
    message.error.should.have.a.property('message').that.equals('error message');
});

Add support for multiple ws options

Add support for configuring multiple ws creation options.

For example, ws sockets can be created with new ws(url, protocols, options).

Right now, sockets can only be created with 1 option parameter, effectively removing the ability to set anything but the protocols in the above example.

Add middleware dispatch capabilites

We should add a .use(type, ...handlers) function to the wrapped socket, which allows for a middleware chain based on the type property in a message. Middleware should include a (msg, ws, next) parameters, similar to express.

Add header support

We should add header support to http style request/responses, Similar to the express .set methods.

Non-object JSON messages fail in onMessage

When sending a string, array, or other non-object message to the server in JSON form, such as ""hello"" the default parser reads it into "hello". The onMessage handler then fails to attach isRequest, because the message is a string. The same is true for arrays.

We may need to add an object check in the default parse, so it throws if the parsed value is not an object after parsing.

Default double encoding of strings

If a string message is sent via the library, the default JSON stringify converts it to a double quoted string.

For example, Rapport.create(WebSocket).send('hello') will send ""hello"" to the peer.

We need to add a string check to the default stringify function, to prevent doubling up encoding on strings.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.