TIBCO Cloud™ Messaging - Unity3D Package
The Implementation is based on standard UnityWebSocket and is working in Unity3D Editor, Android ARCore, and on Microsoft Hololens (UWP).
TIBCO Cloud Messaging Panel
Once connected, the application can receive real-time messages and update the scene accordingly. It can also publish data to be consumed by other applications.
The Package contains a simple sample Implementation that demonstrates how to display the received data in a Scene TextMesh and how to publish messages.
Intro Video
using Cloud Messaging to interact with simple augmented Objects in AR
Step by Step
Trial Account
register for your own TIBCO Cloud™ Messaging trial account on this Sign-up Form to get your personal ID and Auth-Key under ‘Authentication Keys’ Settings Tab, beside the Subscription ‘Status’.
Import into Unity3D
Just created a new Unity Project and import the ready to use Package from the Packages Folder
Unity3D Library Assets
- drag’n drop the ‘MainController’ Prefab into your scene
- drag’n drop the ‘Text’ Prefab into your scene
- drag’n drop the ‘Text’ Object from your scene to the ‘MainControler’, ‘SimpleTextViewController’ Component to the ‘Text Mesh’ Field
- configure your Web Socket URI and Authkey, in a file named ‘TIBCO-credentials.txt’ placed in TIBCOLabs > Utils > Resources folder.
All set! now run Unity ‘Playmode’, and test your implementation using cURL or Flogo first - e.g. like described below.
Alternative Sample Panels
We provide more advanced sample Panels, both using ‘TextMeshPro’ so the ‘SimpleTextViewController’ need to be slightly modified in his interface.
- FTLPanelPrefab-Basic.unitypackage :: contains used Fonts, Images, etc. and can be used in any Unity Project e.g. ARCore Projects.
- FTLPanelPrefab-MRTK.unitypackage :: supports repositioning, follow-me, re-sizing, this sample is build for Hololens and need MRTK.
Use the Sample scene
In the Unity project a test scene is available at TIBCOLabs > CloudMessaging > Sample > CloudMessaging-TestScene
The ARCore Implementation contains additionally a AR Sample scene: TIBCOLabs > CloudMessaging > CloudMessaging-AR
The Scene contains a MainController Object. In the MainController, you can update the Connection property prefix (default is “eftl”).
You can also modify the matcher list. The sample is subscribing to message containing the field “dataType”.
TIBCO Cloud Messaging FTL Configuration
The credentials, ie Web Socket URI and Authkey must be declared in a file named “TIBCO-credentials.txt” and place in a Resources folder. You can use
TIBCOLabs > Utils > Resources
The folder contains a sample for you to copy.
If you manage you credential file in git, it is a good practice to ignore TIBCO-credentials.txt so no credentials get checked-in with your source code.
Credential file
The file must contain [prefix].socketurl and [prefix].authkey with the values from your TIBCO Cloud™ Subscription Details. [prefix] being defined in the connection configuration panel.
sending Messages
The sample is expecting this type of message:
{"dataType":"Power","data":"130"}
The ARCore Sample supports as well an ‘Any’ Datatype, more can be implemented in the ‘SimpleTextViewController’ > ‘OnData’ Handler.
{"dataType":"Any","data":"some Text/Alert from the Cloud"}
using cURL
TIBCO Cloud Messaging comes with a REST API, as well. So any REST Tool can be used for testing, too. Just replace [your-id] and [your-key] in the following command:
curl -i -u :[your-key] https://messaging.cloud.tibco.com/tcm/TIB_SUB_[your-id]/channel/v1/publish -d '{"dataType":"Power","data":"130"}'
using Flogo
Here a sample using TIBCO Cloud™ Integration Flogo
TIBCO Cloud Integration Configuration
In Action
Step by Step Video with TIBCO Messaging in Augmented Reality
How it works
Publish Messages
- you can always publish messages by e.g. using the following
JsonObject message = new JsonObject();
message["demo_tcm"] = msg;
this.Publish(message);
you should always use a JSON format to publish messages, the above sample get subscribed by the TCM Demo Web App.
Subscribe Messages
- The MainController GameObject contains the TIBCO Cloud™ Messaging Connector and SimpleTextViewController
- The SimpleTextViewController extends ‘OnData’ Handler, it requires a connection (Connector Object) and receives messages.
- The SimpleTextViewController has a reference to the TextMesh to update when it receives a message.
the ARCore and Hololens Sample Projects use ‘TextMeshPro’ an a pre-defined Panel Object, instead of just ‘TextMesh’.
TCM Demo Web App
Message Publication
The sample is also publishing messages on the TIBCO Cloud™ Messaging channel. Those message have a field “demo_tcm” and can be viewed in the TIBCO Cloud™ Messaging demo.
To see the message published by the app, simply use TIBCO Cloud™ Messaging Demo app : From you TIBCO Cloud™ Messaging console, open the help panel and select “Run the demo”
Accessing TIBCO Cloud Messaging Demo app
You will access the Demo app. Messages published by our sample application will appear in the Subscriber panel of this demo app.
TIBCO Cloud Messaging Demo app panels
Message Subscription
to subscribe to TIBCO Cloud™ Messaging channel, the Messaging Connector ‘Matcher’ have to be configured, to contain the following:
{"demo_tcm":true}
In the SimpleTextViewController.cs add the lines marked here:
Unity - SimpleTextViewController.cs
Target Devices
Tested with Microsoft Hololens, Android Smartphones, inside Unity Editor on Windows 10.
Used Versions
- Unity (2019.2.18f1)
- Unity AR Foundations (3.1.0)
- Unity AR Subsystem (3.1.0)
- Unity ARCore XR Plugin (3.1.0)
- TIBCO Cloud Nimbus (Release Jan.2020)
- Android 10
- Google Pixel XL
- Microsoft Hololens V1,V2
Content
ready to use Package | min. Implementation, as Unity Project Source
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.