Coder Social home page Coder Social logo

prism-client's Introduction

Prism Client

Connect to a Prism Server from the browser or a remote Node app.

Example

var prismClient = require('prism-client');
var rtt = require('rtt-engine.io')();

var transport = rtt.client({port: 3001, host: 'localhost'});
var app = prismClient({transport: transport});

app.connect(function(err, info){

  console.log("Connected to Prism Server %s with Session ID %s", info.version, info.sessionId);
  
  app.discover(function(){
    console.log('Available services are', app.api);
  });

});

API

View API

Connecting from another Node process

Please see the REPL client example in examples/repl.js.

Note: Not all transports support Node.js clients. rtt-engineio and rtt-ws do.

Connecting from a PhoneGap app

I've not tried this yet, but in theory it should be possible. You may need to use PersistJS. Please get in touch to let me know how you get on.

Providing Services

A Prism Server will be running one or more Realtime Services. Each Service will probably (but not necessarily) contain code to be run on the client (accessible via the app.api object).

Client's can either be told what services are available in advance (using app.provide()), or discover them upon connection (using app.discover()).

We recommending providing service info in advance where possible as this minimizes the traffic over the WebSocket. It also allows for the client-side code to be minimized and served by CDNs.

Prism Server can make this easy for you by building a custom client module containing all the code you need for the transport and services. Just call server.buildClient();.

However it's not always possible to know what Services are provided by a server until you connect. For example, you may want to run a query over the REPL against a remote server. In this case, you'll need to call app.discover() upon initial connection.

License

MIT

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.