1.1.3 • Published 8 years ago

socket.io-rpc-client v1.1.3

Weekly downloads
47
License
MIT
Repository
github
Last release
8 years ago

socket.io-rpc-client Build Status js-standard-style

client library for a socket.io-rpc

All libraries are written in commonJS module style, so you need to use SystemJS loader to be able to use them in the browser. Browserify/webpack might work, if you set it up correctly, but might be a pain and you're probably will have to delve deep into the code. Angular.js lib contains special rpc-controller directive, which when compiled asynchronously loads server channel and instantiates classic angular controller when this channel is ready. #Usage npm install socket.io-rpc-client for serverside usage

jspm install socket.io-rpc-client for clientside usage

then in Node.js:

var rpcClient = require('socket.io-rpc-client');

var rpc = rpcClient('http://localhost:8032');
//call to the server
rpc('plain')().then(function(ret) {
	console.log('plain returned ', ret);	//for test-utils/sample-server.js server prints out: plain returned 41
});
//expose some for the server to call
rpc.expose({
	fnOnClient: function() {
		console.log('called client method');
		return 42;
	},
	asyncOnClient: function() {
		return new Promise(function(resolve, reject) {
			setTimeout(function(){
				resolve('resolved after 40ms');
			}, 40);
		});
	},
	erroringMethod: function() {
		notdefined.error.will.propagate;
	}
});

in the browser:

var myChannel = require('rpc/test');   //CJS style require
//or
import {default as myChannel} from 'rpc/myChannel'; //ES6 style require

myChannel.getTime().then(t => { //calls getTime function on the server
    console.log("t", t);    //t is the serverside return value or serverside promise resolve value
});    

For complete examples including server side refer to socket.io-rpc project

1.1.3

8 years ago

1.1.2

8 years ago

1.1.0

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.3

8 years ago

1.0.2

9 years ago

1.0.0

9 years ago

0.9.11

9 years ago

0.9.10

9 years ago

0.9.9

9 years ago

0.9.8

9 years ago

0.9.7

9 years ago

0.9.6

9 years ago

0.9.5

9 years ago

0.9.4

9 years ago

0.9.3

9 years ago

0.9.2

9 years ago

0.9.1

9 years ago

0.9.0

9 years ago

0.8.15

9 years ago

0.8.13

9 years ago

0.8.12

9 years ago

0.8.11

9 years ago

0.8.10

9 years ago

0.8.9

9 years ago