Coder Social home page Coder Social logo

isabella232 / flying-squirrel-javascript Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rabbitmq/flying-squirrel-javascript

0.0 0.0 0.0 267 KB

JavaScript clients for Flying Squirrel

License: Other

Makefile 0.25% Shell 0.80% JavaScript 92.36% HTML 1.94% CSS 2.95% Python 1.70%

flying-squirrel-javascript's Introduction

Flying Squirrel Javascript Client

Flying Squirrel Client

The Flying Squirrel Client is built on top of socket.io library. Put that inside html "head" tag:

<script type="text/javascript"
        src="http://cdn.socket.io/stable/socket.io.js"></script>

<script type="text/javascript"
        src="http://cdn.squirr.us/flyingsquirrel-client-0.0.0.js"></script>

To establish a client connection you need two variables transport_url and ticket.

var connection = new flyingsquirrel.Connection(TRANSPORT_URL, TICKET);

connection.subscribe('recv-channel', function (msg) {
    alert("got a message " + msg);
});
connection.publish('send-channel', value),

connection.connect();

Documentation

Connection object

var connection = new flyingsquirrel.Connection(transport_url, ticket, [options]);

Options:

  • debug (false) - enable extra debugging.
  • socket_opts ({}) - extra socket.io flags, see socket.io documentation for details.

Methods:

  • connect()
  • disconnect()
  • publish(channel, body)
  • subscribe(channel, callback)
  • request(channel, question, callback)
  • serve(channel, callback)

Flying Squirrel API

The Flying Squirrel API requires jQuery library. Put that inside html "head" tag:

<script type="text/javascript"
        src="http://code.jquery.com/jquery-1.6.min.js"></script>

<script type="text/javascript"
        src="http://cdn.squirr.us/flyingsquirrel-api-0.0.0.js"></script>

To connect to Flying Squirrel service need the api_url.

var api = new flyingsquirrel.API(API_URL);

var endpoint = api.create_endpoint("echo_example",
                                   {'send-channel': ['pub', 'echo],
                                    'recv-channel': ['sub', 'echo']});

var transport_url = endpoint.protocols['socket.io'];
var ticket = api.generate_ticket("echo_example", 'test_user');

Documentation

API object

var api = new flyingsquirrel.API(API_URL);

Methods:

  • get_endpoint(name, [callback])
  • create_endpoint(name, definition, [callback])
  • delete_endpoint(name, [callback])
  • list_endpoints([callback])
  • generate_ticket(name, identity, [callback], [timeout])

flying-squirrel-javascript's People

Contributors

dumbbell 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.