Example name: Simple text chat
Description: A trivial demonstration of WebORB Messaging, in which multiple instances of this sample application use a Remote Shared Object (RSO) to share chat messages.
Prerequisites: [none]
Client-side code: Browse  Download
Server-side code: [none]
Feature availability:
  • WebORB for .NET Development Mode
  • WebORB for .NET Community Edition
  • WebORB for .NET Enterprise Edition
Run example:
Key points:
  • The two screens above are two independent instances of the same SimpleTextChat application. (They are as independent as if they were being run on two different computers, miles apart).
  • In the establishConnection() method, each instance:
    • gets a reference to THE SAME remote SharedObject (and assigns it to the SimpleTextChat application's global variable 'so'), and
    • registers handleSync() to listen for SYNC events from 'so'.
  • When any ONE application's instance's sendIM() method calls so.setProperty(), 'so' sends a SYNC event to the handleSync() method of EVERY running instance ofthe SimpleTextChat application.
  • EVERY instance then updates its chatMessages TextArea component to show the new chat message.
  • For each Messaging application you deploy into a given installation of WebORB, you MUST create a directory with the same name as the application in that installation of WebORB's /Application directory.
    • For example, the installation of WebORB that's running this online sample is installed at IIS virtual directory http://examples.themidnightcoders.com, which IIS maps to the file system directory [confidential]/WebORB4 on our web server.
    • So, to make this sample work online, I had to add a directory named SimpleTextChat to [confidential]/WebORB4/Applications.
    • This directory is EMPTY. However, this sample is trivial. A non-trivial messaing application (NonTrivialApp) would require the use of an app.config file (in [confidential]/WebORB4/Applications/NonTrivialApp/app.config).
  • The application method onCreationComplete() (main.mxml, lines 26-41) ensures that WebORB's Messaging server is up and running. If no fault occurs, then establishConnection() (main.mxml, lines 45-67) is called.
  • main.mxml's line 52 is: var uri:String = ServerConfig.getChannel( "weborb-rtmp" ).endpoint. It returns (and assigns to uri) the path to the WebORB installation's Applications directory.
  • main.mxml's line 53 is: nc.connect( uri + "/SimpleTextChat" ). The result of appending "/SimpleTextChat" to uri is the path to SimpleTextChat's directory in the Applications directory.
   
Things to try:
  • While keeping this window open, open this page in a different browser window (perhaps on a different machine). Enter a new name, and send new chat messages. They should appear in both instances of the SimpleTextChat application, in both browser windows.
  • Call friends in another city, and get them to open this page in their browsers. Enter chat messages. Verify that you can each see each others' chat messages.
  • Build this application on your development machine. Run it. Chat messages will NOT be shared among clients. Why not? Because building the downloaded sample code does not create a SimpleTextChat directory in your [WebORB]/Applications directory. Add that (empty) directory. Run the sample again. It 'should' work.
See also:
Screencast: [none]
Errata:
  • None yet known.