Introduction
Beginning with Intuiface version 3.5, we enhanced our remote actions syntax with a REST-based API. REST - the acronym for "representational state transfer" - is a model for requesting services and returning responses over the Web, aka Web services. It has become the most popular Web services model due to its simplicity.
NOTE: Only experiences running in Player for Windows (either standalone or in Composer's Play Mode) can be remotely controlled. It is not possible to remotely control experiences running in Player for other platforms like Android, iPad, Chrome etc.
The power of REST
Using the Intuiface Rest API you can remotely call every action available in Intuiface. The syntax is quite simple. Consider the Next action. Calling it remotely is as easy as :
http://127.0.0.1:8000/intuifacepresentationplayer/presentation/Next
(Of course, this particular URL will only work if you are running Intuiface Player or Composer on your local computer, the famous local host with an IP address of 127.0.0.1).
A complete API is available here in the Knowledge Base, but we have also developed an interactive webpage to help you define and test your remote action URLs. It is available at https://myintuiface.intuilab.com/remote-actions-builder
Creating your own remote control
Using the REST API creates novel options for interaction. With it you can interact with your experience not only by touching the actual display, but also at a distance using media like a Web browser or a tablet.
This is a fairly easy task because calling REST Web services is a very common activity on both iOS and Android.
Android code :
try {
HttpParams httpParameters = new BasicHttpParams();
// Set the timeout in milliseconds until a connection is established.
// The default value is zero, meaning a timeout is not used.
HttpConnectionParams.setConnectionTimeout(httpParameters, 5000);
// Set the default socket timeout (SO_TIMEOUT)
// in milliseconds which is the timeout for waiting for data.
HttpConnectionParams.setSoTimeout(httpParameters, 5000);
final HttpGet req = new HttpGet("http://<IP_address>:8000/intuifacepresentationplayer/presentation/Next");
final HttpClient client = new DefaultHttpClient(httpParameters);
String result = client.execute(req, new BasicResponseHandler());
} catch (Exception e) {
Log.e("RemoteException", ""+e.getMessage());
throw new Exception("Unable to execute remote action", e);
}
iOS code:
// call the action and retrieve result as NSData (useful for Intuiface Presentation snapshots)
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://10.0.0.192:8000/intuifacepresentationplayer/presentation/forward?transition=swipe&duration=1&extraparams=null&responseformat=XML"] options:nil error:nil];
// retrieve the result as a string, useful for actions such as getcurrentspace
NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
As you can see, executing a remote action is straightforward and does not require much code. Combining the REST API with tablet development can lead you to advanced interactive communication between your Intuiface experiences and third party applications, including your own. It is just a matter of imagination...
Comments
0 comments
Article is closed for comments.