Code Monkey home page Code Monkey logo

angular-websocket-service's Introduction

angular-websocket-service is a WebSocket service for AngularJS. Use it to send and receive messages consisting of a topic string (without spaces) followed by a space and a JSON payload. For example:

/state/put {"name": "Alice", "friends": ["Bob", "Charlie"]}

The user-facing API is:

  • $websocket.connect(endpoint) to return a new wrapped WebSocket object connected to the WebSocket server at endpoint.

Wrapped WebSocket instances have the following user-facing API:

  • emit(topic, body) to send outgoing messages. Messages send before the WebSocket connects are queued until the connection completes.
  • register(topic, callback[, options]) to add a callback for incoming messages. The callback fingerprint should be callback(topic, body). The callback is triggered for messages who's topic starts with the registered topic. For example, callbacks registered for /state and /state/get will both be invoked for a /state/get message. You can optionally pass in an options object to configure the registration. For example, if you do want an exact topic match (instead of a prefix match), use {exact: true} (a callback registered for /state will exact set to true will not be invoked for a /state/get message).

Similar packages

  • angular-websocket sends and receives opaque messages using a send method and events with a configurable prefix (MIT). The event-generating code is not clear to me, so I'm not actually sure how the prefix bit works.
  • angular-websocket-provider sends and receives JSON messages using a request method and websocket.<METHOD> and websocket.message events. <METHOD> is set using the payload's method value (GPLv2).
  • angular-reconnecting-websocket wraps websockets to automatically reconnect after accidental disconnections (MIT).

angular-websocket-service's People

Contributors

btford avatar shofetim avatar wking avatar

Watchers

 avatar  avatar  avatar

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.