// get the record
var driver = client.record.getRecord( 'driver/14' );
// subscribe to any changes within position
driver.subscribe( 'position', function( position ){
updateMarker( position.x, position.y );
});
// subscribe to the event
client.event.subscribe( 'chat-msg', function( msgText ){
console.log( msgText );
});
// remote procedure call for "times-three" with 7
client.rpc.make( "times-three", 7, function( err, result ){
// And get 21 back
console.log( result );
});
// get the record
Record r = client.record.getRecord( "driver/14" );
// subscribe to any changes within position
r.subscribe( "position", new RecordPathChangedCallback() {
public void onRecordPathChanged(String recordName,
String path, JsonElement position) {
updateMapMarker( position );
}
});
// subscribe to any event
client.event.subscribe("chat-msg", new EventListener() {
// receive any serializable data
public void onEvent(String eventName, Object msgText) {
System.out.println( msgText );
}
});
// Make a remote procedure call
RpcResult rpcResponse = client.rpc.make( "times-three", 7 );
// And get 21 back
System.out.println( rpcResponse.getData() );
// get the record
var driver = client.record.getRecord( 'driver/14' );
// and every time the driver moves
navigator.geolocation.watchPosition(function( pos ){
// send its position
driver.set( 'position.x', pos.coords.latitude );
driver.set( 'position.y', pos.coords.longitude );
});
// emit events with any kind of serializable data
client.event.emit( 'chat-msg', 'how\'s life?' );
// register as a provider
client.rpc.provide( 'times-three', function( num, response ){
// ...and respond to requests
response.send( num * 3 );
});
// implements android.location.LocationListener
public void onLocationChanged(Location location) {
// get the record
Record record = client.record.getRecord( "driver/14" );
// any kind of data path works
record.set( "position.x", location.getLongitude() );
//as well as any kind of serializable datatype
record.set( "position.y", location.getLatitude() );
}
// emit events with any kind of serializable data
client.event.emit( "chat-msg", "how's life?" );
// register as a provider
client.rpc.provide("times-three", new RpcRequestedListener() {
// this method will be invoked once another client calls rpc.make
public void onRPCRequested(String rpcName, Object data, RpcResponse response) {
// data can be any kind of serializable object
response.send( (Double) data * 3 );
}
});
Case Study:How deepstream helped Briteback take enterprise communication to the next level
Tutorial: Building a multiplayer spaceshooter with deepstream.io and pixi.js
Case Study:How deepstream helped iValue8 build realtime analytics for shopping malls
Case Study:Building a stock trading platform in the cloud using deepstream
Tutorial: Deploying deepstream with MongoDB and Redis on digital ocean
Interactive JSON documents that can be edited and observed. Changes are persisted and synced across clients.
Many clients can subscribe to topics and receive data whenever other clients publish it to the same topic.
Clients can register functions to be called by other clients. deepstream will smartly route requests and responses.
discover deepstreamHub.com - a global cloud platform combining rock-solid deepstream hosting with integrated usermanagement, analytics and a wealth of other features