Flex provides many benefits and advantages over alternative client-side technologies. In my opinion one of the most powerful features available in Flex (and Flash) is the support for video streaming and recording. To make it easier for developers to include these (and many other RTMP-based) features, we added a very cool code generator into the latest releases of WebORB for Java and .NET. With a few mouse clicks the code generator can instantly create a complete Flex project containing all the ActionScript code enabling video recording, video broadcast, communication via remote shared objects and server-side data push. The video linked below provides an overview of this fantastic functionality. Enjoy!
I am very happy to report that we released a new version of WebORB for Java – version 4.3. The theme of the release is ‘Developer Productivity’. As you may already know, WebORB enables integration at four different levels: remoting (RPC), data management, real-time publish/subscribe messaging and video/audio streaming and recording. With this release, we deliver code generators for all of these levels of integration. Below is a brief description of the new features you will find in 4.3:
Data management for JavaScript Clients – If you’re familiar with WebORB, more than likely you know about our data management framework. If not, then you can learn about it either from the WebORB Data Management documentation or the Data Management webinar recording. In short, the framework lets you quickly import your database schema into our Data Modeller tool and generate client and server-side code to enable full CRUD with your data from the ActionScript or JavaScript client or the server-side code. The same code generator can also create a demo application which demonstrates the power of the API. The JavaScript client support lets you create a data-driven ORM solution for your database in seconds. In addition to the APIs for CRUD operations, the JavaScript client also supports client-synchronization for the changes done by other clients working with the same dataset.
Remoting code generator for Robotlegs - Robotlegs is quickly becoming a popular ActionScript framework. We included a very powerful code generator which can generate all the supporting ActionScript classes for a given Java service (POJO, EJB, Spring bean, Grails service or SOAP web service) . The generated code enables remoting with the service and includes all the supporting classes conforming to the Robotlegs framework. This includes controller, events, mediators and ActionScript value objects. Read more about WebORB and Robotlegs integration.
Native Android Java code generator and invocation client - WebORB includes a tiny native Java library supporting remote procedure calls of the WebORB hosted services from native Android Java applications. Additionally, we also added a code generator which can create Java client-side code for any given WebORB service. The generated project also includes a visual invoker to make it easier to see the generated code in action.
Windows Phone invocation client (with code generator)- similar to the native Android Java library, we also added a native Windows Phone (Silverlight) client-side library into the WebORB distribution. Using the library Windows Phone applications can easily integrate with WebORB-hosted Java services using either RPC or publish/subscribe APIs. There is also a code generator which can create C# code and a sample Windows Phone project for any deployed Java service.
New Swiz code generator – We have completely rewritten the Swiz code generator to support the latest release of the Swiz framework. The generated code includes all the events, pre-wired controller, service invoker and value object types.
Code generator for rich media Flex, AIR and Mobile apps – WebORB for Java supports the RTMP protocol and enables video streaming and recording, remote shared objects and server-side data push. In this release we added a code generator which can create a sample Flex, AIR or mobile application with the code demonstrating all of these features. Optionally, the code can be generated to support RTMP tunneling for any of the selected features. Read more..
Code generator for multi-client Publish Subscribe messaging – WebORB provides native libraries and APIs for publish/subscribe messaging for Flex, AIR, JavaScript, native Java and .NET clients. The unifying concept for all of these APIs is the messaging destination. With the new release, it is trivially easy to manage destinations and on top of this, developers can quickly generate native publish/subscribe messaging apps for all the supported client-side types.
Publish/Subscribe Messaging Test Drive – When you develop a messaging application, it may be very important to be able to observe message traffic over your destination. It is very easy to do that with the new release. Simply open the management console, Find your destination under the Messaging Server tab and click “Test Drive”. The feature lets you both create subscribers and publish test messages.
As you can see it is a feature packed release. We also fixed quite a few bugs and you can access a full report in the Midnight Coders bug tracking system. We plan to publish follow-on posts with videos and examples demonstrating all the new functionality in the coming days.
The example reviewed below demonstrates data push from a server-side Java application to three different native mobile app implementations: iOS, Android and Windows Phone. The server updates the data every 1.5 seconds and delivers it to the clients. The iOS client uses a persistent RTMP connection, the Android and Windows Phone clients use publish/subscribe messaging (via polling) to receive server-side updates. The source code for each mobile implementation and the server-side project (with deployment instructions) is available below the video:
Server-side Compilation and Deployment instructions:
Download and install WebORB for Java (make sure to download version 4.3 or above) .The product is available for free with the Community Edition license. Without a license key, it will work in the “development mode” which will be sufficient to the this example. See WebORB Licensing for additional details.
To compile the Java project, add the following JAR dependencies: weborb.jar, red5.jar, spring-core-3.0.0.jar. All the required jar files can be found in [WEBORB-INSTALL-DIR]/webapp/WEB-INF/lib.
The compiled classes can be deployed to [WEBORB-INSTALL-DIR]/webapp/WEB-INF/classes/examples/weborb (if the package structure changes, the directories under WEB-INF/classes will have to change as well).
Register new messaging destinations. To do this, open [WEBORB-INSTALL-DIR]/webapp/WEB-INF/flex/messaging-config.xml in a text editor, add the following destination declaration before the closing </service> element, then save the file:
Register new RTMP messaging application: To do this create a new XML file with the following contents in [WEBORB-INSTALL-DIR]/webapp/WEB-INF/classes. Name the file stockexchange-web.xml (alternatively, you can download the file from here):
Modify beanRefContect.xml from [WEBORB-INSTALL-DIR]/webapp/WEB-INF/classes by adding the following XML element before the closing </list> element.
<value>stockexchange-web.xml</value>
Run WebORB for Java in a command prompt/terminal window by using the following command (run the command from the WebORB installation directory):
java -jar weborb.jar
Verify that WebORB is running by opening the management console from: http://localhost:8080
Compile and run the mobile applications. Use the following configuration parameters:
iOS – Hostname: if launching in iOS Simulator, use localhost, otherwise enter IP address of the machine where weborb is running. Application name: StockExchange, port – 1935
Android and Windows Phone- WebORB URL – http://localhost:8080/weborb.wo (if running on a device, substitute localhost with the IP address of the machine where WebORB is running).
A few weeks ago we released a communication library for iOS which provides an excellent mechanism for integrating iOS applications with various server-side technologies. The library enables client-server integration via the RTMP protocol and thus requires the server-side code to be deployed into an RTMP. (Btw, we’re working on adding support for basic RPC (remote procedure call) mechanism which make it trivially simple to connect iOS applications with any Java, .NET or PHP class, web service, Spring beans, .NET WCF service, etc). One of the servers the library supports is Wowza Media Server. The video below provides a demonstration of the integration between iOS and Java classes deployed in Wowza. The examples demonstrate the following:
Invocation of Java methods from iPhone
Java data push via an invocation of the Objective C method from Java
Usage of Remote Shared Objects hosted in Wowza Media Server
The rest of this post (below the video) provides details on deploying the same examples in your own environment. We also plan to post similar videos and instructions for other RTMP server implementations, specifically FMS, Red5 and our own WebORB for Java and WebORB for .NET.
Follow the steps below to configure and run the same examples as shown in the video above (disclaimer: I’m not a Wowza Media Server expert and there might be a simpler way to do the configuration/deployment described below. If you know of a simpler or more appropriate way, please submit a comment):
Cross platform application connectivity is to be a frequently requested and talked about feature. A lot of enterprise and consumer-facing applications require robust data exchange mechanism between application instances running on mobile devices. On top of this, many applications depend on real-time updates and notifications pushed from the server to the clients. One of the approaches for cross platform data exchange is a feature called Remote Shared Objects. The video below provides an explanation of the feature as well as a demonstration of iPhone, iPad and Windows Mobile phone communicating with each other as well as a browser-based Flex application.
The demo was built using the latest version of WebORB for .NET (the Java version would work just as well), Communication Library for iOS and a client library for Windows Mobile included into the WebORB distribution. Enjoy!
Integrating .NET applications with other client technologies (or even .NET to .NET) may not seem to be a trivial task. I believe Microsoft has done a great job providing a fairly closed technology stack where things work as long as you stick to Microsoft’s prescription of how to go about solving problems. Take for example the task of creating a multi client messaging system between a .NET application and Flex, AIR, Android or iOS client and you will shortly feel the pain. The real challenge is the .NET messaging framework is not very open to accomodate client applications of other than native .NET or ASP.NET. As a result, you will need a messaging server which will serve the purpose of routing broker and messaging “translator” between heterogeneous client applications.
Earlier this month I wrote about Remote Shared Objects and the benefits the feature provides. Since remote shared objects are no longer a feature exclusive to Flash, Flex and AIR clients I put together a messaging example demonstrating how .NET applications can efficiently communicate with Flex and AIR (and thus Android, iOS and Blackberry Playbook). The .NET application is a simple (console-based) chat program which uses remote shared objects to exchange data with a Flex client. The Remote Shared Object APIand RTMP connectivity comes with the RTMPClient class available in WebORB for .NET. Here’s the full listing of the C# code with an explanation right after the listing:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using Weborb.Client;
using Weborb.Messaging.Net.RTMP;
using Weborb.Messaging.Api.Service;
using Weborb.Messaging.Api.SO;
namespace WeborbClientTest
{
class Program : IPendingServiceCallback, ISharedObjectListener
{
private ThreadStart threadStart;
private Thread chatThread;
private AutoResetEvent rsoIsReady = new AutoResetEvent( false );
private RTMPClient rtmpClient;
private IClientSharedObject rso;
static void Main( string[] args )
{
Program chatClient = new Program();
chatClient.StartChat();
}
public void StartChat()
{
rtmpClient = new RTMPClient();
rtmpClient.setServiceProvider( this );
System.Console.WriteLine( "Connecting to the RTMP server running at localhost:2037" );
rtmpClient.connect( "localhost", 2037, "Chat", null, this );
threadStart = new ThreadStart( MainChat );
chatThread = new Thread( threadStart );
chatThread.Start();
chatThread.IsBackground = false;
}
public void MainChat()
{
rsoIsReady.WaitOne();
System.Console.WriteLine( "Connecting to the 'ChatSO' remote shared object" );
rso = rtmpClient.getSharedObject( "ChatSO", false );
rso.addSharedObjectListener( this );
while( true )
{
System.Console.WriteLine( "Enter a message to put into RSO. Press \"Enter\" to stop the loop:" );
String messageText = System.Console.ReadLine();
if( messageText.Equals( "" ) )
break;
Hashtable messageObject = new Hashtable();
messageObject[ "imText" ] = messageText;
messageObject[ "username" ] = ".NET Client";
messageObject[ "color" ] = 0;
messageObject[ "isBold" ] = false;
messageObject[ "isItalics" ] = false;
messageObject[ "isUnderline" ] = false;
rso.setAttribute( "UserMessage", messageObject );
}
}
public void resultReceived( IPendingServiceCall call )
{
System.Console.WriteLine( "RTMP client connected" );
rsoIsReady.Set();
}
public void onSharedObjectClear( ISharedObjectBase so )
{
System.Console.WriteLine( "EVENT: onSharedObjectClear" );
}
public void onSharedObjectConnect( ISharedObjectBase so )
{
System.Console.WriteLine( "EVENT: onSharedObjectConnect" );
}
public void onSharedObjectDelete( ISharedObjectBase so, string key )
{
System.Console.WriteLine( "EVENT: onSharedObjectDelete" );
}
public void onSharedObjectDisconnect( ISharedObjectBase so )
{
System.Console.WriteLine( "EVENT: onSharedObjectDisconnect" );
}
public void onSharedObjectSend( ISharedObjectBase so, string method, IList parms )
{
System.Console.WriteLine( "EVENT: onSharedObjectSend" );
}
public void onSharedObjectUpdate( ISharedObjectBase so, IDictionary<string, object> values )
{
System.Console.WriteLine( "EVENT: onSharedObjectUpdate" );
}
public void onSharedObjectUpdate( ISharedObjectBase so, Weborb.Messaging.Api.IAttributeStore values )
{
System.Console.WriteLine( "EVENT: onSharedObjectUpdate" );
}
public void onSharedObjectUpdate( ISharedObjectBase so, string key, object value )
{
System.Console.WriteLine( "EVENT: onSharedObjectUpdate" );
Hashtable messageData = (Hashtable) value;
System.Console.WriteLine( "property " + key + ", imText value " + messageData[ "imText" ] );
}
}
}
The StartChat method is where the program connects to the localhost server running on port 2037 (WebORB’s default RTMP port). The “Chat” parameter is the name of the messaging application the client connects to. The main chat logic is in the MainChat method. As you can see from the code the MainChat method is executed by a separate thread. The reason for this is the process of establishing a connection and receiving a notification that the connection has been established (lines 34 and 72) is asynchronous. As a result, a separate thread is required so the main method of the application does not end prematurely.
Inside of the MainChat method, the code uses the getSharedObject method to obtain a reference to the specified remote shared object – ChatSO (line 47). A listener object is added to the remote shared object instance so the application receives all the RSO events, including the one when the RSO is updated (lines 111-117).
Compile the example code (you might need to set the weborb.dll assembly reference)
Run the WebORB Management Console
Run the .NET application
In the management console switch to the Help/Resources tab, then click the Examples link
In the examples tree in the console navigate to: FLEX Examples > Real-time Messaging (RTMP) > Basic Text Chat
Type in a send messages both in the Flex and .NET clients – both send and receive data
To see the contents of the Remote Shared Object used in the sample .NET application switch to the Messaging Server tab in the Management Console, select the Chat node in the tree, then select the Shared Objects tab. As the clients send data, the console shows the internal state of the shared object.
Exactly the same approach and APIs are applicable if you build Android and iOS mobile applications. I plan to write a similar post demonstrating cross platform connectivity and messaging between .NET and Android and iOS clients.
Here’s a brief video showing the example in action: