Abstract:
A system and method for providing a device agnostic framework between two or more computing platforms. The system includes a protocol for creating device agnostic messages including data from a message generated by an application on the first computing platform, as well as identification and targeting data to enable the message to be sent to the intend target computing platform. The intended target computing platform responds via a callback, thereby establishing a communication protocol between the first and second computing platforms regardless of different computing languages or hardware being used.

Description:
FIELD OF THE INVENTION 
       [0001]    The present invention relates to a system and method for providing a multilingual computer framework for sending and receiving messages comprised of objects between different devices and/or operating systems. Specifically, the present invention includes an improved device connectivity framework, which is a system for facilitating communication between two or more software platforms without the need for common computer languages, common operating systems or even common hardware. The system and method includes the use of computerized translation data using a common protocol, the translation data being attached to a message being sent from one software platform to another software platform. This framework thus provides the ability to connect software applications that are aware of one another &amp; can exchange data with other applications that utilize the same framework or protocol. The present invention has particular applicability in any field where there is a need for bridging a communication gap between computer applications. 
       BACKGROUND OF THE INVENTION 
       [0002]    Computer applications offer a wide variety of functionality capabilities, each with their own fortes and limitations. In addition, the increase in internet connectivity (especially in mobile applications) has resulted in an increase in web based computer programs. One such class of applications are known as Rich Internet Applications, or RIAs. An RIA is a Web application that has many of the characteristics of desktop application software, typically delivered either by way of a site-specific browser, via a browser plug-in, independent sandboxes, use of JavaScript, or virtual machines. Adobe Flash, JavaFX, and Microsoft Silverlight are currently the three most common platforms, with desktop browser penetration rates around 96%, 76%, and 66% respectively as of August 2011. Mobile phone penetration of these plugins, however, has remained low even as internet traffic from these devices has grown. Although new Web standards have emerged, they still use the principles behind RIAs. Users generally need to install a software framework using the computer&#39;s operating system before launching the application, which typically downloads, updates, verifies and executes the RIA. 
         [0003]    A further problem with such software usage is the limitations of frameworks and similar mechanisms for facilitating such connections are platform dependent. For example, a given RIA cannot use the same framework to permit an application to communicate equally with a Java based application and a Flash based application. This limitation, understandably, limits the utility of RIAs and the potential they offer to users and content providers alike. 
         [0004]    Thus, the present state of the art reflects a need for a device connectivity framework which operates with browser based access to native application code, as well as having the ability to enable such communication without regard to the software platforms involved. 
       DESCRIPTION OF THE PRIOR ART 
       [0005]    One example of a prior art approach is found in Microsoft&#39;s OLE technology, as well as its successors MS ActiveX and Microsoft&#39;s .NET initiative. The .NET initiative includes Microsoft Silverlight, a graphical user interface technology that enables user-experience driven applications to run both inside and outside of the Web browser. ActiveX controls allow for browser-based HTML applications to communicate with applications running on a client computer and external resources. However, ActiveX requires the MS Internet explorer browser and the MS Windows operating system, along with client code created to run on the Windows environment. 
         [0006]    Another prior art approach was made available by the present inventors through the Merapi Project. Merapi is a Java™ application, intended to run on a user&#39;s (client) computer. Merapi connects other Java applications on the user&#39;s computer to Adobe AIR™ applications that the user has installed. With Merapi, the Adobe AIR application must be developed in a way that allows it to connect to Merapi. Merapi acts as a “middle man”, passing objects between a user&#39;s AIR application and a Java application. The Merapi Project is thus a software “bridge” that allows Adobe AIR (psuedo-desktop/thin-client) applications to use native code, written in Java, at runtime, on the same local machine on which the AIR application is being run. However, the Merapi Project fails to enable or suggest browser-based access to native code. Likewise, the Merapi Project fails to teach the ability to execute native code other than Java. 
         [0007]    What is needed is a device and platform agnostic computer communication system between multiple software platforms which includes browser based access to native code. 
       Definition of Terms 
       [0008]    The following terms are used in the claims of the patent as filed and are intended to have their broadest plain and ordinary meaning consistent with the requirements of the law. 
         [0009]    A “device agnostic message” is computerized communication data provided to an intended target which includes or is derived from at least both native data from a computer platform sending the communication as well as translation data such that the message may be processed by the intended target. 
         [0010]    “Computerized instruction data” is a command or communication derived from an application on a first software platform which is made available to a second software platform. 
         [0011]    “Target information” is information which identifies the intended recipient(s) of a given device agnostic message. Such information may include, but is not limited to information specifying a particular computer address and/or computer communication port. 
         [0012]    “Translation data” is computerized information which allows processing of the computerized instruction data in a device agnostic message to be processed by a given target software platform without requiring the native application for such computerized instruction data. 
         [0013]    Where alternative meanings are possible, the broadest meaning is intended. All words used in the claims set forth below are intended to be used in the normal, customary usage of grammar and the English language. 
       OBJECTS AND SUMMARY OF THE INVENTION 
       [0014]    The apparatus and method of the present invention generally includes a computer platform agnostic device connectivity framework for enabling computer messages to flow between at least a first computer platform and a second computer platform without need for any common hardware or software applications or languages. The frame typically includes the creation of a message by a first application, the appendage or creation of a device agnostic message using the message by the first application and attaching identification a d/or target data thereto, sending the device to an intended target using the identification and/or target data, and receive of a response message or callback message from the intended target acknowledging receipt of the device agnostic message. 
         [0015]    An immediate application of one embodiment of the present invention will be seen in enabling communications from a first software platform (e.g., a desktop application such as an Adobe Flash application) to a remote, second software platform (e.g., a mobile phone application such as an Android application). However, those of skill will understand that certain objects of the present invention will similarly be met through a second embodiment wherein the first and second software platforms reside on the same device (e.g., by providing device agnostic messages through a communications port between two applications using different languages but residing on the same desktop computer). 
         [0016]    Thus can be seen that one object of the present invention is to provide a device connectivity framework or method and system which enables communications with and instruction data being provided from a first computer platform to a second computer platform regardless of whether the two platforms employ the same applications, language or hardware. 
         [0017]    A further object of the present invention is to provide a system and method for enabling remote communication of computer instructions between two different software platforms without requiring common software languages or applications. 
         [0018]    Still another object of the present invention is to provide a system and method which enables the coding of computer instructions from a first application such that they can be operated upon by a recipient computer regardless of the applications native to the recipient computer. 
         [0019]    Yet another object of the present invention is to provide a system and method whereby a web application, such as a browser, can communicate with and process instructions from a native device application on the same or a different computer regardless of the language used by the native device application. 
         [0020]    Still another object of the present invention is to provide a system and method which enables a distributed connectivity framework architecture which uses an intermediate device (including cloud or internet connected hardware devices) to enable the passage of instructions and communications between two different applications on two different remote computing devices without requiring the same applications to reside on such computing devices. 
         [0021]    It should be noted that not every embodiment of the claimed invention will accomplish each of the objects of the invention set forth above. In addition, further objects of the invention will become apparent based the summary of the invention, the detailed description of preferred embodiments, and as illustrated in the accompanying drawings. Such objects, features, and advantages of the present invention will become more apparent in light of the following detailed description of a best mode embodiment thereof, and as illustrated in the accompanying drawings. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0022]      FIG. 1  shows an operational schematic of a first preferred embodiment of the device connectivity framework operating between two applications on the same device. 
           [0023]      FIG. 2  shows an operational schematic of a second preferred embodiment of the device connectivity operating between two applications on two different remote devices. 
           [0024]      FIG. 3  shows a variant of the second preferred embodiment with additional data types contained with the device agnostic message. 
           [0025]      FIG. 4  shows a further example of the first preferred embodiment of the device connectivity framework operating between to applications on the same computing device. 
           [0026]      FIG. 5  shows still a further example of the first preferred embodiment of the device connectivity framework enabling communications between two web applications on the same computing device. 
           [0027]      FIG. 6  shows an example of the second preferred embodiment of the device connectivity framework enabling communications between a web application on a first computing device and an Android application on a second, remote computing device. 
           [0028]      FIG. 7  shows a further example of the second preferred embodiment of the device connectivity framework enabling communications between a web application on a first computing device and a native application on a second, remote computing device. 
           [0029]      FIG. 8  shows an example of a third preferred embodiment of the device connectivity framework enabling communications between a web application on a first computing device and a native application on a second, remote computing device via a cloud device connectivity framework. 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0030]    Set forth below is a description of what is currently believed to be the preferred embodiment or best examples of the invention claimed. Future and present alternatives and modifications to this preferred embodiment are contemplated. Any alternatives or modifications which make insubstantial changes in function, in purpose, in structure or in result are intended to be covered by the claims in this patent. 
         [0031]    A first embodiment of the present invention is shown in  FIG. 1 , which addresses a situation in which there exists a need for communication between a web application and a native computer application on a single hardware device. For instance, in this embodiment, a user might wish to access a first proprietary, legacy application on a hardware device using a second software application (e.g., a web browser or other application) in order to provide a superior graphical user interface without requiring the hardware device going out to a server. In such an embodiment the device connectivity framework system occurs within the confines of a first computing device  10 , such as a desktop, laptop, tablet, or handheld computer (e.g., a smartphone). Residing on the first computing device  10  are a first application  12  and a second application  14 . The ability to communicate between the two applications in accord with the method and system of the present invention, i.e., without requiring a common language or without operating through an outside server, begins with the step of the first application creating a message  16 , e.g., generating an instruction or communication intended for the second application. The message  16  requires the step of creating a device agnostic message  18 . This device agnostic message  18  includes data  20  derived from the step of creating a message, and adds to that data a unique identifier or ID  19  that identifies the intended target of the device agnostic message, and further adds a device address  22 , which in the example of this first preferred embodiment could simply be the identification of a designated communications portal (socket) which would be used for handling the device agnostic messages of the present invention. 
         [0032]    In response to receiving the device agnostic message  18 , the second application  14  would most preferably generate a callback  24  which is passed back from the second application to the first application  12 . The callback, in one example of the first embodiment, could simply be verification to the first application  12  that the device agnostic message  18  had been received and would thus call or initiate further subroutines or operations in the first application  12  which would result in creation of further messages  16 . Of course, those of skill would understand the present invention could use the same system and method to create messages  26  by the second application  14  which using the same device agnostic message format  18 , would be processed and recognized by the first application and cause the creation of a callback  30  to the second application  14 . Additionally, those of ordinary skill would understand that the framework of the present invention could be used to combine the callback  30  and create messages  26  steps to practice an embodiment within the scope of the present invention. 
         [0033]    A second embodiment of the present invention is shown in  FIG. 2 , which addresses a situation in which there exists a need for communication between a web application on a first hardware device and a native computer application on a second hardware device. For instance, a user may desire the ability to have a web browser application on a first device interface with a native application (e.g., a so-called smart board application) which uses separate hardware. For example, the user may have access to a web browser displaying a web application depicting a globe and offering web tools for drawing upon the globe picture. In addition, the first computer device may have attached to it a smart board and smart board tools (e.g., a smart board pen) for marking upon the smart board. The present framework would enable the user to operate the smart board pen on the smart board to implement changes on the globe being depicted as if he or she were operating the software web tools on the web application. In the system  100  of this second embodiment, the first computing device  110  has a first application  112  (e.g., a browser) which creates a message  114  intended for a second application  122  on a second device  120 . As with the first embodiment, this framework involves the first application  112  creating a message  114 . The message  114  is used to provide the data  134  for a device agnostic message  130 , which further includes at least a unique identifier or ID  132  and an address  136  for the second computing device  120 , e.g., the IP internet address. As with the first embodiment, upon receipt of the device agnostic message  130 , the second application  122  generates a callback  124  which is sent back to the first computer application. Also as with the first embodiment, the device agnostic message framework of this embodiment may be used to create messages  126  by the second application, such message  126  being sent to the first application  112  which in turn generate a callback  116  from the first application  112  to the second application  122 . 
         [0034]      FIG. 3  disclosed a variant of the second preferred embodiment which is identical to that disclosed in  FIG. 2  except for the additional requirement within the composition of the device agnostic message. Specifically, in this variant of the present invention, the device agnostic message  130  further includes an intent component  138  for enabling a specific command which directs a certain action to be taken by the recipient second computer device  120 . For example, the instruction may be from a first application  112  to a second computer device  120  instructing the device (or an application on the device) to turn on. In this embodiment the intent acts like an address for number of recipients or listeners listening for a specific type of message, and the messages are instructions are the ones which directs certain actions. Thus, for example, a single first application, e.g., a web application, on a first device could provide communications and instructions with a number of remote computers identifying a meeting for a particular group on a given date. In such an event, the communications could be received and processed by one or more remote computers which would act upon such communications so long as they are members of the group, and further so long as the software application recognizes the message, e.g., a calendaring application might record the date of the meeting in response to the message, but a presentation application might not recognize the message, and thus would ignore it. 
         [0035]    As shown in  FIGS. 4 and 5 , examples of the first  12  and second  14  applications may be, respectively, a large native application, and a presentation application, or a web application (browser)  12  and a second web application  14 . The specific choices of applications are not material to the scope of present invention, except that the first application  12  and second application do not have to use the same language or have the same instruction set to operate, and the functionality of the present invention requires some level of communication between the first and second applications such that the interaction between the two is to the benefit of the user and/or the application providers. In the example of  FIG. 4 , the first embodiment may be employed, for example, where the user desires to have his or her first application (a large native application) provide rich content to a second application  14  which is a presentation application. In the example of  FIG. 5 , by contrast, both the first and second applications  12 ,  14  are web browser applications. In both of these examples, the system includes a helper service  40  which, in these examples, comprises a helper application install on the computing device. The functionality of this helper service would be present in  FIG. 1 , but would be provided, for example, by the addition of software code into the first and second applications. The embodiments of  FIGS. 4 and 5 , by comparison, are particularly useful where, for example, the proprietary nature of the software makes the integration of the helper service  40  into the code of the first application  12  impractical. The function of the helper service  40  is to provide the mechanism for handling the device agnostic messages between the first and second applications. For example the HTML or AJAX code in the first application  12  communicates with an embedded shockwave flash file (.SWF)(not shown), and the helper file, in turn, communicates with local components, such as drivers to enable any control or actuation of the device which desired as a result of the communication between the first and second applications. 
         [0036]    The system  100  of  FIGS. 6 and 7  are variants and examples of  FIG. 2  showing an example of the present invention in communication between a first computing device  110  and a second computing device  120 . The interface of this example is enabling by the helper service  140 , which passes device agnostic messages  130  between the first and second computing devices. In this example, the first application creates a device agnostic message  130  whereby the first computing device start and searches the local network for another computing device which is enabled for the helper program  140 . Once communication is established based upon a device agnostic message  130 , the present system enables data objects to be passed seamlessly between the first application  112  and the second application  114  through TCP communications via sockets (not shown) thus enabling what appears to the user to be a multi-screen experience (e.g., the screen display and functionality of the second computing device  114  receives and displays the screen display of the first computing device  112 ). 
         [0037]    In order to help those of skill in practicing the present invention, the following source code disclosure is provided. This code corresponds to the practice of the invention shown in  FIG. 6 . The sample of code constitutes of the following different components:
       1. Helper Service  140  (which in this example is a Windows Service implemented using c#)   2. DCF SWF Library part of Web Application  112  (Flex library implemented using action script)   3. Web Application  112  (Built using HTML and JavaScript)   4. Android Native Application [ 122 ] (android apk package)       
 
         [0042]    First, the following module illustrates the implementation of the Helper Service  140  using C#: 
       DCF Helper Service  140  Codebase 
       [0043]    Service class which invokes the Listener class of the Helper Service 
       ListenerService Implementation 
       [0044]      
         [0000]                                            namespace RaVt.ListenerService            {            partial class Service1 : ServiceBase            {             public Service1( )             {                //initializes the windows service component              InitializeComponent( );             }             protected override void OnStart(string[ ] args)             {                //on start of the service                //invokes the Listener initialize              RaVt.Listener.Program.Initialize( );             }             protected override void OnStop( )             {              RaVt.Listener.Program.Close( );             }            }           }                        
Listener class which is responsible instatiating the DCF C# Library which is part of the Helper Service  140 
 
       Listener Module Implementation 
       [0045]      
         [0000]    
       
         
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 namespace RaVt.Listener 
               
               
                   
                 { 
               
               
                   
                  public class Program 
               
               
                   
                  { 
               
               
                   
                   static void Main(string[ ] args) 
               
               
                   
                   { 
               
               
                   
                      //invokes the initialize method of the listener class 
               
               
                   
                    Initialize( ); 
               
               
                   
                   } 
               
               
                   
                   // Initializes the Listener class 
               
               
                   
                   public static void Initialize( ) 
               
               
                   
                   { 
               
               
                   
                    // Execute all the startup commands 
               
               
                   
                      //which are configured in a config.cs class 
               
               
                   
                    CommandUtil.ExecuteCommands- 
               
               
                   
                    (Config.START_UP_COMMANDS, 
               
               
                   
                         Assembly.GetAssembly(typeof(Program))); 
               
               
                   
                   } 
               
               
                   
                  } 
               
               
                   
                 } 
               
               
                   
                   
               
             
          
         
       
     
       Listener Conifg Class Implementation 
       [0046]      
         [0000]                                namespace RaVt.Listener       {        public class Config        {         // The Listener DCF Port         public const int DCF_PORT = 12365;         public const int SERVICE_MANAGER_PORT = 12364;         // Commands to execute on startup, which triggers the execute       method in the respective classes         public static readonly Type[ ] START_UP_COMMANDS = {       typeof( OpenFirewallPortsCommand ),                typeof( DCFStartupCommand ),                typeof( StartMessageHandlersCommand ) };         // Commands to execute on close         public static readonly Type[ ] CLOSE_BRIDGE = { typeof(         DCFStopCommand ) };         public static readonly Type[ ] STOP_COMMANDS = { typeof(       CloseFirewallPortsCommand )};        }       }                    
The following classes are executed or invoked as part of the Helper Service  140  Startup.
 
The following class module is responsible for adding exception rules to the windows firewall for the specific port or ports:
 
       Listener OpenFireWallPorts Class Implementation 
       [0047]      
         [0000]                                namespace RaVt.Listener.Commands       {        // Command class responsible for opening the required ports on all accessible Firewalls        public class OpenFirewallPortsCommand : Command        {          //constants         protected const string WIN_XP_ARGS = “firewall add portopening tcp 12365 \“Support       Helper\””;         protected const string WIN_VISTA_7_ARGS = “advfirewall firewall add rule       name=\“Support Helper\” dir=in action=allow protocol=TCP localport=12365”;         protected const string NETSH = “netsh”;         // utility method to start a windows process in the background         public static Process StartProcess( string cmd, string args, bool show, bool waitForExit )         {          ProcessStartInfo psi = new ProcessStartInfo( cmd, args );          Process p = new Process( );          if ( !show )          {           psi.CreateNoWindow = true;           psi.UseShellExecute = false;          }          p.StartInfo = psi;          p.Start( );          if ( waitForExit )           p.WaitForExit( );          return p;         }       //The execute method is invoked as part of the start up command //OpenFirewallPortsCommand       parameter         public void Execute( )         {          // Vista and Windows 7          if ( Environment.OSVersion.Version.Major == 6 )          {           StartProcess( NETSH, WIN_VISTA_7_ARGS, false, false );          }          // Windows XP          else if ( Environment.OSVersion.Version.Major == 5 )          {           StartProcess( NETSH, WIN_XP_ARGS, false, false );          }         }        }       }                    
The following class is responsible for instantiating the DCF Policy server and opening the DCF Socket Connection Bridge which is part of DCF C# Library, all of which are components of the Helper service  140 
 
         [0000]                                namespace RaVt.Listener.Commands       {       //Command class responsible for setting up ConnectITDCF.          //Starts a Cross Domain Policy server and then the        ConnectITDCF bridge.        public class DCFStartupCommand : Command        {          //Executes the functionality for setting up ConnectITDCF         public void Execute( )         {          // Start the PolicyServer that responds to cross domain requests          // Service Manager Port in this case is 12364          PolicyServer.DEFAULT_PORT =          Config.SERVICE_MANAGER_PORT;          PolicyServer.Start( );          // Setup the DCF Bridge and open the socket          Bridge.PORT = Config.DCF_PORT;          Bridge.Open( );         }        }       }                    
The following code implements the DCF C# Library part of Helper Service  140 , which acts as a connection host for the Web Application  112 .
 
       DCF C# Library Implementation 
     PolicyServer Class Implementation 
       [0048]      
         [0000]                                namespace DCF       {        // Class PolicyServer        // Starts a PolicyServer on the specified port.        public class PolicyServer        {         // If no argument is passed the server will listen on this port for connections         public static int DEFAULT_PORT = 12344;         public static String[ ] DEFAULT_POLICY = new String[ ] { “*” };         // The character sequence sent by the DCF Flash object or SWF to request a _policy file         public const String POLICY_REQUEST = “&lt;policy-file-request/&gt;”;         // starts the policy server       // the server uses the port param to listen on for connections         public static void Start( )         {          int port = DEFAULT_PORT;          // new policy server is started          PolicyServer server = new PolicyServer( port, new String[ ] { “*:80” } );          new Thread( server.Run ).Start( );         }         // PolicyServer class local variables         private int _port;         private bool _listening;         private Socket _socketServer;         private static String _policy;         // PolicyServer constructor         // param port_ Sets the port that the PolicyServer listens on         public PolicyServer( int port_, String[ ] allowedHosts_ )         {          _port = port_;          _listening = true;          if ( allowedHosts_ == null ) allowedHosts_ = DEFAULT_POLICY;          _policy = buildPolicy( allowedHosts_ );         }       // Constructs the cross domain policy string for the DCF Flash       //   object or SWF component         private String buildPolicy( String[ ] allowedHosts_ )         {          StringBuilder policyBuffer = new StringBuilder( );          policyBuffer.Append( “&lt;?xml version=\“1.0\”?&gt;&lt;cross-domain-policy&gt;” );          policyBuffer.Append( “&lt;site-control permitted-cross-domain-policies=\“by-content-       type\”/&gt;” );          for ( int i = 0; i &lt; allowedHosts_.Length; i++ )          {           String[ ] hostInfo = allowedHosts_[ i ].Split( new char[ ] { ‘:’ } );           String hostname = hostInfo[ 0 ];           String ports;           if ( hostInfo.Length &gt; 1 ) ports = hostInfo[ 1 ];           else ports = “*”;       // allows access from domains to the following port, which is       // which is 12365 for our DCF Socket Bridge           policyBuffer.Append( “&lt;allow-access-from domain=\“” + hostname + “\” to-       ports=\“12365\” /&gt;” );          }          policyBuffer.Append( “&lt;/cross-domain-policy&gt;” );          return policyBuffer.ToString( );         }         // Thread run method, accepts incoming connections and creates SocketConnection objects       to handle requests         public void Run( )         {          try          {           _listening = true;           // Start listening for connections           _socketServer = new Socket( AddressFamily.InterNetwork, SocketType.Stream,                ProtocolType.Tcp );           _socketServer.Bind( new IPEndPoint( IPAddress.Any, _port ) );           // start listening...           _socketServer.Listen( 4 );           while ( _listening )           {            // Wait for a connection and accept it            Socket socket = _socketServer.Accept( );            try            {             // Start a new connection thread             new Thread( new SocketConnection( socket ).Run ).Start( );            }            catch ( Exception e )            {                logger.Error( “Exception: ” + e.ToString( ) );            }            // Wait for a sec until a new connection is accepted to avoid flooding            Thread.Sleep( 1000 );           }          }          catch ( IOException e )          {              logger.Error( “IO Exception: ” + e.ToString( ) );          }         }         // Local class SocketConnection         For every accepted connection one SocketConnection is created.          It waits for the _policy file request, returns the _policy file and closes the connection       immediately         class SocketConnection         {          private Socket _socket;          private StreamReader _socketIn;          private StreamWriter _socketOut;          // Constructor takes the Socket object for this connection          @param socket_ Socket connection to a client created by the PolicyServer main thread          public SocketConnection( Socket socket_ )          {           _socket = socket_;          }          // Thread run method waits for the _policy request, returns the poilcy file and closes the       connection          public void Run( )          {           readPolicyRequest( );          }          // Wait for and read the _policy request sent by the Flash Player          Return the _policy file and close the Socket connection          private void readPolicyRequest( )          {           try           {            // Read the request and compare it to the request string defined in the constants.            // If the proper _policy request has been sent write out the _policy file            String readData = read( );            if ( POLICY_REQUEST.Equals( readData ) ) Write( _policy );           }           catch ( Exception e )           {            if ( DEBUG ) System.Console.WriteLine( “PolicyServer.readPolicyRequest( ) ” +       e.ToString( ) );           }           Close( );          }          // Read until a zero character is sent or a maximum of 100 character          private String read( )          {           byte[ ] buffer = new byte[ _socket.ReceiveBufferSize ];           _socket.Receive( buffer );           StringBuilder strb = new StringBuilder( );           foreach ( byte byt in buffer )           {            if ( byt == (byte)0 ) break;            strb.Append( (char)byt );           }           return strb.ToString( );          }          // Writes a String to the client          @param msg Text to be sent to the client (_policy file)          public void Write( String msg )          {           msg += “\u0000”;           char[ ] chars = msg.ToCharArray( );           byte[ ] buffer = new byte[ chars.Length ];           int idx = 0;           foreach ( char chr in chars )           {            buffer[ idx ] = (byte)chr;            idx++;           }           _socket.Send( buffer );          }          // Close the Socket connection an set everything to null. Prepared for garbage collection          public void Close( )          {           try           {            if ( _socket != null ) _socket.Close( );            if ( _socketOut != null ) _socketOut.Close( );            if ( _socketIn != null ) _socketIn.Close( );           }           catch ( IOException e ) { System.Console.WriteLine( e ); }           _socketIn = null;           _socketOut = null;           _socket = null;          }         }        }       }                    
The following code implements the DCF Socket Connection Bridge in DCF C# Library which is part of the Helper Service  140 .
 
       Bridge Class Implementation 
       [0049]      
         [0000]                                                                                                                                                                                                                    namespace DCF       {        // The Bridge class is a singleton gateway to the Flex DCF bridge.        // IMessages are exchanged between this C# bridge object and the Flex bridge object.        // @see DCF.events.DCFEvent        // @see DCF.Messages.IMessage;        public class Bridge        {           // Class Constant                public const String CONFIG_PATH   = “./config/DCF-native-config.xml”;           public const String READER_STRING   = “reader”;           public const String WRITER_STRING   = “writer”;           public const String PORT_STRING     = “port”;                // The port used to connect DCF Bridge which is configured from Helper Service           public static int PORT   = 12365;           // The single instance of the DCF Bridge         public static Bridge GetInstance( )         {           if ( Instance == null )           {                 Instance = new Bridge( );                // Registers the Message handlers which are message Types                 Instance.RegisterHandlers( );           }          return Instance;         }         // Opens the DCF server socket, which is invoked from Helper Service         public static void Open( )         {           if ( Thread == null )           {                   Bridge.Thread =   new Thread( Bridge.GetInstance( ).Run );                   Bridge.Thread.Start( );              Bridge.IsRunning   = true;            }          }         // Closes the DCF server socket which is invoked from the Helper Service          public static void Close( )          {                 Bridge.IsRunning   = false;            Bridge.Thread      = null;                 try            {            Instance._server.Close( );            }            catch ( IOException exception )            {                  logger.Error( exception );            }          }            // Local Class Variables               private static Bridge   Instance   = null;          private static Thread   Thread   = null;          private static bool    IsRunning   = true;               // Bridge class Constructor          private Bridge( )          {            ReadConfig( );              handlers = new Dictionary&lt;String, List&lt;IMessageHandler&gt;&gt;( );          }          // The run method of the thread            public void Run( )            {               try               {                     server = new Socket( AddressFamily.InterNetwork,       SocketType.Stream,                  ProtocolType.Tcp );               server.Bind( new IPEndPoint( IPAddress.Any, PORT ) );               server.Listen( 4 );                  while( true )                  {                // Get the first client that connects                         Socket temp =    server.Accept( );                       client = temp;                    // Instantiate a listener thread that will listen and read the input       stream                    // of the first client that connects and start the thread                       clientListenerThread = new BridgeListenerThread( _client,           reader );            new Thread(    clientListenerThread.Run ).Start( );                 }              }              catch ( Exception e )              {                    logger.Error( e );              }           }           // Dispatches an IMessage to registered listeners.           public void DispatchMessage( IMessage message )           {          List&lt;IMessageHandler&gt; list = null;              // Get the list of handlers registered for the event type          if (    handlers.ContainsKey(message.type) == false )          {           return;          }          else          {           list =    handlers[message.type];           if ((list != null) &amp;&amp; (list.Count &gt; 0))           {            foreach (IMessageHandler handler in list)            {             handler.HandleMessage(message);            }           }          }           }           // Registers an IMessageHandler to receive notifications when a certain message type       is dispatched. These Message Types acts a target.           public void RegisterMessageHandler( String type, IMessageHandler handler )           {              // Get the list of handlers registered for the event type          List&lt;IMessageHandler&gt; list = null;          if (    handlers.ContainsKey( type ) )          {           list =    handlers[ type ];          }          else          {             // If the list is null, create a new list to add ‘handler’ to               list = new List&lt;IMessageHandler&gt;( );                  handlers.Add( type, list );             }             // Add the handler to the list             list.Add( handler );           }         // Sends a message to the DCF Flex Object or SWF component side of the DCF bridge.           public void SendMessage( IMessage message )         {             if (    client == null ||    client.Connected == false ) return;             byte[ ] bytes =    writer.write( message );          // Send the length of the message first          byte[ ] lenBytes = new byte[4];          lenBytes[0] = (byte)(bytes.Length &gt;&gt; 24);          lenBytes[1] = (byte)(bytes.Length &gt;&gt; 16);          lenBytes[2] = (byte)(bytes.Length &gt;&gt; 8);          lenBytes[3] = (byte)bytes.Length;          //send the header             client.Send(lenBytes);          // Send the message             client.Send(bytes);           }           // Unregisters a given handler.           public void UnRegisterMessageHandler( String type, IMessageHandler handler )           {          IMessageHandler localHandler = null;          // Get the list of handlers registered for the event type          List&lt;IMessageHandler&gt; list =    handlers[type];          // If the list is not null and not empty, look for handler in the list and remove it if a match       is found          if (list != null &amp;&amp; list.Count &gt; 0)          {           foreach (IMessageHandler activeHandler in list)           {            if (activeHandler == handler)            {             localHandler = handler;            }           }           list.Remove(localHandler);          }           }         // Instantiates the framework IMessageHandlers           protected void RegisterHandlers( )           {             // Registers SystemExecuteHandler as the IMessageHandler of the             // SystemExecuteMessage.SYSTEM_EXECUTE message type.              new SystemExecuteMessageHandler( );           }           // The socket that open connections to the Flex DCF bridge.                private Socket       server   = null;                // The socket that connected to the Flex DCF bridge.                private Socket       client               = null;           // The thread that listens for messages from the Flex client socket.                private BridgeListenerThread       clientListenerThread   = null;                // The IWriter used to serialize data sent across the bridge to Flex.                private IWriter       writer   = new            AMF3Writer( );           // The IReader used to deserialize data that comes across the bridge from Flex.                private IReader       reader   = new            AMF3Reader( );           // A Dictionary of registered event handlers.           private Dictionary&lt;String, List&lt;IMessageHandler&gt;&gt;    handlers = null;        }       }                    
The following code implements the BridgeListenerThread class which is responsible for reading the Message  130  from Web Application  112  and notifying the DCF C# Library Bridge which is part of the Helper Service  140 .
 
       BridgeListenerThread Class Implementation 
       [0050]      
         [0000]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          namespace DCF       {                // The BridgeListenerThread listens for messages from a client socket and notifies the bridge            when a message is received.                public class BridgeListenerThread           {                // Constructor.                public BridgeListenerThread( Socket client, IReader reader ) : base( )           {                  —— client   = client;                  —— reader   = reader;                  }                // The run method of the thread that reads data from the input stream. When a            messaged is deserialized it is broadcasted from the bridge via Bridge.dispatchEvent. Registered       listeners are notified of the event.                public void Run( )                {                byte[ ] bytes = null;           bool firstRead = true;           List&lt;IMessage&gt; messages = null;                // When the first byte returns is equal to −1, the socket has been           disconnected           // we let the thread end at this point.                while ( firstRead == true ∥ ( bytes != null &amp;&amp; bytes.Length &gt; 0 &amp;&amp;                bytes[ 0 ] != Int32.Parse( “−1 ” ) ) )                {                firstRead = false;           while (  —— client.Available == 0 )           {                Thread.Sleep( 500 );                }             —— logger.Debug(  —— client.Available + “ bytes recv&#39;d.” );           try                 {                 bytes = new byte[  —— client.Available ];             —— client.Receive( bytes );            byte firstByte = bytes[0];                 // check to see if message is AMF or JSON                 if (firstByte != Int32.Parse(“10”))            {                  —— logger.Debug(“Message is not an AMF object”);           messages = jsonRead(bytes);                 }            else            {                messages =  —— reader.read(bytes);                 }            if ( bytes != null &amp;&amp; bytes.Length &gt; 0 )            {                  —— logger.Debug( “First byte: ” + bytes[ 0 ] );                 }           if ( messages != null &amp;&amp; messages.Count &gt; 0 )           {                foreach ( IMessage message in messages )           {                // Broadcast the Message from the Bridge           Bridge.GetInstance( ).DispatchMessage( message );                }                }           else           {                bytes = null;                }                }           catch ( Exception exception )           {                bytes = null;                }                }                }           public List&lt;IMessage&gt; jsonRead(byte[ ] bytes)           {                MemoryStream ms = new MemoryStream( );           foreach (byte b in bytes)           {                 ms.WriteByte(b);                }           ms.Position = 0;           StreamReader sr = new StreamReader(ms);           string msgstr = sr.ReadToEnd( );           Console.WriteLine(msgstr);           IMessage message = null;           List&lt;IMessage&gt; messages = new List&lt;IMessage&gt;( );           Dictionary&lt;string, object&gt; objdata = DeserializeJSON(msgstr);           Console.WriteLine(“Message Type:” + objdata[“type”].ToString( ));           Message m = new Message( );           m.type = objdata[“type”].ToString( );           m.data = objdata[“data”];           m.uid = objdata[“uid”].ToString( );           message = m;           messages.Add(message);           return messages;                }           #region JSON utility Methods           public Dictionary&lt;string, object&gt; DeserializeJSON(string json)           {                var d = new Dictionary&lt;string, object&gt;( );           if (json.StartsWith(“{”))           {                json = json.Remove(0, 1);           if (json.EndsWith(“}”))                json = json.Substring(0, json.Length − 1);                }           json.Trim( );           // Parse out Object Properties from JSON           while (json.Length &gt; 0)           {                var beginProp = json.Substring(0, json.IndexOf(‘:’));           json = json.Substring(beginProp.Length);           var indexOfComma = json.IndexOf(‘,’);           string endProp;           if (indexOfComma &gt; −1)           {                endProp = json.Substring(0, indexOfComma);           json = json.Substring(endProp.Length);                 }            else            {                endProp = json;           json = string.Empty;                 }            var curlyIndex = endProp.IndexOf(‘{’);            if (curlyIndex &gt; −1)            {                var curlyCount = 1;           while (endProp.Substring(curlyIndex + 1).IndexOf(“{”) &gt; −1)           {                curlyCount++;           curlyIndex = endProp.Substring(curlyIndex + 1).IndexOf(“{”);                }           while (curlyCount &gt; 0)           {                endProp += json.Substring(0, json.IndexOf(‘}’) + 1);           json = json.Remove(0, json.IndexOf(‘}’) + 1);           curlyCount−−;                }                }           json = json.Trim( );           if (json.StartsWith(“,”))                json = json.Remove(0, 1);                json.Trim( );           // Individual Property (Name/Value Pair) Is Isolated           var s = (beginProp + endProp).Trim( );           // Now parse the name/value pair out and put into Dictionary           var name = s.Substring(0, s.IndexOf(“:”)).Trim( );           var value = s.Substring(name.Length + 1).Trim( );            if (name.StartsWith(“\″”) &amp;&amp; name.EndsWith(“\″”))            {                 name = name.Substring(1, name.Length − 2);                 }            double valueNumberCheck;            if (value.StartsWith(“\″”) &amp;&amp; value.StartsWith(“\″”))            {                 // String Value            d.Add(name, value.Substring(1, value.Length − 2));                 }            else if (value.StartsWith(“{”) &amp;&amp; value.EndsWith(“}”))            {                 // JSON Value            d.Add(name, DeserializeJSON(value));                 }            else if (double.TryParse(value, out valueNumberCheck))            {                 // Numeric Value            d.Add(name, valueNumberCheck);                 }            else                 d.Add(name, value);                }           return d;                }           #endregion JSON utility Methods                // The client connected from the UI side of the bridge.                private Socket     —— client = null;                // The reader used to deserialize Objects sent across the bridge.                private IReader     —— reader = null;                }            }                    
The following code Implements the SystemExecuteMessageHandler and SystemExecuteMessage class which acts as a utility to execute any system process from the Web Application  112 .
 
       SystemExecuteMessage Handler Class Implementation 
       [0051]      
         [0000]    
       
         
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
             
           
               
                   
               
             
             
               
                 namespace DCF.systemexecute.handlers 
               
               
                 { 
               
             
          
           
               
                   
                 public class SystemExecuteMessageHandler : MessageHandler 
               
               
                   
                 { 
               
             
          
           
               
                   
                 // The default constructor 
               
               
                   
                 public SystemExecuteMessageHandler( ) 
               
             
          
           
               
                   
                  : base( SystemExecuteMessage.SYSTEM_EXECUTE ) 
               
             
          
           
               
                   
                 { 
               
               
                   
                 } 
               
               
                   
                 // Handles an IMessage dispatched from the Bridge. 
               
               
                   
                 public void handleMessage( IMessage message ) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 if ( message is SystemExecuteMessage ) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 SystemExecuteMessage sem = (SystemExecuteMessage)message; 
               
               
                   
                 // Use the args passed in the message to do a shell exec 
               
               
                   
                 try 
               
               
                   
                 { 
               
             
          
           
               
                   
                 string[ ] args = sem.args; 
               
               
                   
                 if ( args.Length &gt; 1 ) 
               
               
                   
                 { 
               
             
          
           
               
                   
                   —— logger.Debug( “Executing ” + args[ 0 ] + “ ” + args[ 1 ] + “.” ); 
               
               
                   
                 System.Diagnostics.Process.Start( args[ 0 ], args[ 1 ] ); 
               
             
          
           
               
                   
                 } 
               
               
                   
                 else if ( args.Length == 1 ) 
               
               
                   
                 { 
               
             
          
           
               
                   
                   ——  logger.Debug( “Executing ” + args[ 0 ] + “.” ); 
               
               
                   
                 System.Diagnostics.Process.Start( args[ 0 ] ); 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                   
                 } 
               
               
                   
                 catch ( Exception e ) 
               
               
                   
                 { 
               
             
          
           
               
                   
                   —— logger.Error( e ); 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                 } 
               
               
                   
               
             
          
         
       
     
       SystemExecuteMessage Class Implementation 
       [0052]      
         [0000]                                                                                                                                                namespace DCF.systemexecute.messages       {                // The SystemExecuteMessage class is a sub class of Message that            signals a system execute request from the UI layer.                public class SystemExecuteMessage : Message           {                // Message type for a system execute command.           public const string SYSTEM_EXECUTE = “systemExecute”;           // Constructor.           public SystemExecuteMessage( ) : base( )           {           }           // A set of args to use as the system execute parameters           public string[ ] args           {                get           {                Object[ ] data = (Object[ ])base.data;           String[ ] args = new String[ data.Length ];           for ( int i = 0; i &lt; data.Length; i++ )           {                args[ i ] = (String)data[ i ];                }           return args:                }                }                }            }                    
The following code implements the MessageHandler class and IMessageHandler interface of the DCF C# Library which is part of the Helper Service  140 .
 
       IMessage Handler Interface Implementation 
       [0053]      
         [0000]    
       
         
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
             
           
               
                   
               
             
             
               
                 namespace DCF.Handlers 
               
               
                 { 
               
             
          
           
               
                   
                 // The IMessageHandler interface defines the methods for receiving a 
               
             
          
           
               
                   
                 Message from the Bridge. 
               
             
          
           
               
                   
                 public interface IMessageHandler 
               
               
                   
                 { 
               
             
          
           
               
                   
                 // Handles an IMessage dispatched from the Bridge. 
               
               
                   
                 void HandleMessage( IMessage message ); 
               
               
                   
                 // Removes all types being listened for by this IMessageHandler 
               
               
                   
                 void UnregisterAllTypes( ); 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                 } 
               
               
                   
               
             
          
         
       
     
       Message Handler Class Implementation 
       [0054]      
         [0000]                                                                                                                                                                                        namespace DCF.Handlers       {                public class MessageHandler : IMessageHandler           {                // The default constructor           public MessageHandler( )           {           }           // Automatically registers the handler for message type.           public MessageHandler( String type )           {                AddMessageType( type );                }           // Handles an IMessage dispatched from the Bridge.           public virtual void HandleMessage( IMessage message )           {           }           // Removes all of the type messages registered, cleaning up            anyexternal references held by the Bridge to this Handler                public virtual void UnregisterAllTypes( )           {                String[ ] types = Types.ToArray( );           foreach ( String type in types )           {                RemoveMessageType( type );                }                }           // Adds another message type to be listend for by this instance of           MessageHandler.           public void AddMessageType( String type )           {                Types.Add( type );           Bridge.GetInstance( ).RegisterMessageHandler( type, this );                }           // Removes the handling of message type.           public void RemoveMessageType( String type )           {                Types.Remove( type );           Bridge.GetInstance( ).UnRegisterMessageHandler( type,           this );                }           // The types this handler is registered to listen for           protected List&lt;string&gt; Types = new List&lt;string&gt;( );                }            }                    
The following code implements the IMessage interface and Message class which are of type Message  130 .
 
       IMessage Interface Implementation 
       [0055]      
         [0000]    
       
         
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
             
           
               
                   
               
             
             
               
                 namespace DCF.messages 
               
               
                 { 
               
             
          
           
               
                   
                 // The IMessage interface describes a ‘message’ sent from the DCF 
               
               
                   
                 Flex bridge. 
               
               
                   
                 public interface IMessage 
               
               
                   
                 { 
               
             
          
           
               
                   
                 // The message type. 
               
               
                   
                 String type 
               
               
                   
                 { 
               
             
          
           
               
                   
                 get; 
               
               
                   
                 set; 
               
             
          
           
               
                   
                 } 
               
               
                   
                 // The data of the message. 
               
               
                   
                 Object data 
               
               
                   
                 { 
               
             
          
           
               
                   
                 get; 
               
               
                   
                 set; 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                 } 
               
               
                   
               
             
          
         
       
     
       Message Class Implementation 
       [0056]      
         [0000]                                                                                                                                                                                                                                                                                                                                        namespace DCF.messages       {                // The Message class implements IMessage, a ‘message’ sent from                the DCF Flex bridge.                public class Message : IMessage           {                // Convience method to check if a message matches a type.           public static bool IsType( IMessage message, string type )           {                return type.Equals( message.type );                }           // Constructor.           public Message( )           {                this.uid = System.Guid.NewGuid( ).ToString( );                }           // Constructor.           public Message( String type )                : this( )                {                this.type = type;                }           // Constructor.           public Message( String type, Object data )                : this( type )                {                this.data = data;                }           // The type of the message.           public String type           {                get { return  —— type; }           set {  —— type = value; }                }           // A unique ID for this message.           public String uid           {                get { return  —— uid; }           set {  —— uid = value; }                }           // The data carried by this message.           public Object data           {                get { return  —— data; }           set {  —— data = value; }                }           // Sends this message across the bridge.           public void send( )           {                try           {                Bridge.GetInstance( ).SendMessage( this );                }           catch ( Exception e )           {                  —— logger.Error( e );                }                }           // Used by the getters/setters.           private String  —— type = null;           private String  —— uid = null;           private Object  —— data = null;                }            }                    
With the above code implementing the DCF C# Library which acts as Host Bridge, which is part of the Helper Service  140 , the present embodiment involving continuing to implement the rest of the start up commands from the Listener initialization.
 
       Continuation of the Listener Startup Commands 
       [0057]    The following code implements the StartMessageHandlersCommands class part of Helper Service  140 , which instantiates all the message handler types for Listener class. 
       StartMessageHandlers Class Implementation 
       [0058]      
         [0000]                                                                                                                                                namespace RaVt.Listener.Commands       {                // Command class responsible for starting the required           MessageHandlers.           public class StartMessageHandlersCommand : Command           {                // The MessageHanders to start           public static readonly Type[ ] MESSAGE_HANDLERS = {            typeof( ListenerMessageHandler ) };                // Executes the functionality for instantiating the all the Handler           Types           public void Execute( )           {                // Instantiate each handler in the MESSAGE_HANDLERS           array           Assembly assembly = Assembly.GetAssembly(           this.GetType( ) );           if ( MESSAGE_HANDLERS != null &amp;&amp;           MESSAGE_HANDLERS.Length &gt; 0 )           {                foreach ( Type type in MESSAGE_HANDLERS )           {                assembly.CreateInstance( type.FullName );                }                }                }                }            }                    
The above code instantiates all the message handlers, which are configured as part of the Listener class of the Helper Service  140 .
 
The following code implements the ListenerMessageHandler type which is part of the Listener class and registers all the Message Types that are supported by the Listener which is part of the Helper Service  140 .
 
       ListenerMessageHandlers Class Implementation 
       [0059]      
         [0000]                                                                                                                                                                    namespace RaVt.Listener.Handlers       {                // Handles ListenerMessages           class ListenerMessageHandler : MessageHandler           {                // The default constructor adds the ListenerMessage types handled            by ListenerMessageHandler           public ListenerMessageHandler( )           {                AddMessageType(START_ON_DEMAND );           AddMessageType(STOP_ON_DEMAND);                }            // The entry point for ListenerMessages recieved from the web ui,       // will be handled in this override methos                public override void HandleMessage( IMessage message )           {                if ( message.type.Equals( ListenerMessage.START_ON_DEMAND ) )           {                // Handles the start on demand meesage type from web ui                HandleStartOnDemand(message);                }           else if (message.type.Equals(ListenerMessage.STOP_ON_DEMAND))           {                HandleStopOnDemand(message);                }                }            }                    
The above code handles any Message  130  of the added types, that DCF C# Library reads from the Web Application  112 .
 
The above code thus implements the Helper Service  140  part of the code, which acts a like a host to the Web Application  112  client in order to communicate to the external android device  120 . What follows is an example of the Client side portion of the code. With the Helper Service  140  windows service running on the first computing device  110 , a user can start a browser based Web Application  112  which constitutes the following HTML object code to instantiate the DCF Flex Library which is part of the Web Application  112  client.
 
         [0000]                                                                                                                                                                &lt;object id=“Listener” classid=“clsid:D27CDB6E-AE6D-11cf-96B8-444553540000”                width=“0” height=“0”           codebase=“http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab”&gt;           &lt;param name=“movie” value=“@Url.Content(“~/swf/dcf.swf”)” /&gt;           &lt;param name=“allowScriptAccess” value=“always” /&gt;           &lt;embed src=“@Url.Content(“~/swf/dcf.swf”)” quality=“high” bgcolor=“#869ca7”                width=“0” height=“0” name=“Listener” align=“middle”           play=“true”           loop=“false”           allowScriptAccess=“always”           type=“application/x-shockwave-flash”           pluginspage=“http://www.adobe.com/go/getflashplayer”&gt;                &lt;/embed&gt;                &lt;/object&gt;            // The javascript stores the listener dom element in a global variable called bridge       &lt;script type=“text/javascript”&gt;                var bridge = document[‘Listener’];            // The following javascript method tries to establish a connection with the DCF Listener service.       function connectToListener( ) {                 var listenerCallback = function (message) {                if (message.type == CONNECT_FAILURE_ERROR) {                // handles the connection failure                }           else if (message.type == CONNECT_SUCCESS) {            // handles the connection success           }                 }           // registers the Listener Message Types for the client side           registerListenerMessageTypes(listenerCallback);           //call to connect to the DCF Flex bridge           connectRADCF( );                }            &lt;/script&gt;                    
The following code implements the javascript methods to connect to DCF Flex bridge which is part of the HTML application DOM in the Web Application  112 , using action script external interface.
 
The following code implements the Message  130  JavaScript object prototype for the Web Application  112  Client.
 
       Message Prototype Implementation 
       [0060]      
         [0000]                                                                                                  // The Message class is a ‘message’ sent or received by the DCF UI layer.                function Message(type, data) {                // Properties           this.type = type;           this.data = data;                }            // The Message Prototype properties.                var uid;           var type;           var data;           // Sends the message across the DCF bridge.           Message.prototype.send = function( )           {                bridge.sendMessage( this );                }                        
The following code implements the JavaScript MessageHandler object prototype to add, remove and handle Message  130  from the external android device  120  through the Helper Service  140  using the DCF Bridge.
 
       MessageHandler Prototype Implementation 
       [0061]      
         [0000]                                                                                                                                                                                                                          // The MessageHandler class defines the methods for receiving a Message from the Bridge.                function MessageHandler( )           {           }           // Handles a message dispatched from the Bridge. This method should be overridden by            MessageHandler sub class definitions / instances.                MessageHandler.prototype.handleMessage = function(message) {           }           // adds message types to the DCF Flex Bridge instance for Particular handler type           MessageHandler.prototype.addMessageType = function(type) {                // Registers the type w/ the bridge. If the type has           // been registered, it is ignored on the action script Flex library           bridge.registerMessageHandler(type);           // If this is the first handler registered for the type,           // create an Array to store the handlers in the map           if (handlersMap[type] == null) {            handlersMap[type] = new Array( );           }           // Map the message type to the respective handler types           handlersMap[type].push(this);                }           // Removes the handling of message type           MessageHandler.prototype.removeMessageType = function( type )           {                // true if there is another listener still listening to           // this message type           var stillListening = false;           // The list of handlers registered for Message type           var list = handlersMap[ type ];           if ( list != null )           {                // Find the handler in list that matches this           // instance and remove it           for ( i=0; i&lt;list.length; i++ )           {                // if list[ i ] matches this listener, remove it           if ( list[ i ] == this )           {                list[ i ] = null;                }           // if list[ i ] is not null, then there are still           // handlers listening to this type           else if ( list[ i ] != null )           {                stillListening = true;                }                }                }                //first we need to pop the type from array and then unregister           handlersMap[type].splice(handlersMap[type].indexOf(this), 1);           bridge.unRegisterMessageHandler(type);                // if there are still handlers listening to the type,           // don’t unRegister with DCF Flex library otherwise if all handlers           // for this type are removed, then we can unregister the           // type from the bridge           if ( stillListening == false )           {                bridge.unRegisterMessageHandler( type );                }                }                        
The following code implements the JavaScript methods to initiate the socket connection from the Web Application  112  using the DCF Flex Library&#39;s external interface modules.
 
         [0000]                                                                                                                                                                                                                                                                                      // connects the DCF client/ui Bridge to the DCF Flex Bridge.       function connectRADCF( port, host )       {                try {                // forcing the port to 12365, because the Helper Service Bridge is listening on that port                bridge.connectDCF(″12365″, host);                }           catch (ex) {           }            }       // disconnects the DCF client/ui Bridge to the native Bridge.       function disconnectRADCF( )       {                bridge.disconnectDCF( );            }       // Performs a systemExecute via a proxy call to the DCF Flex Library.       // args are passed in as array of params       function systemExecute( args) {                bridge.systemExecute( args );            }       // The external callback for any messages that have a type that was registered, for any type that       has been registered. The list of handlers that have registered is looked up in handlersMap and       handleMessage( ) is called on each registered handler.       function handleDCFMessage(message) {                // The list of handlers registered for messsage.type           var list = handlersMap[ message.type ];           // If the list is null there′s nothing to do           if ( list != null )           {                // Call handleMessage( ) on each handler registered           // for message.type           for( i=0; i&lt;list.length; i++ )           {                if ( list[ i ] != null )           {                list[ i ].handleMessage( message );                }                }                }            }       // Maps registered message types to a list of the associated handlers registered for the type.       var handlersMap = new Object( );       // DCF Constants       // Event type for a serialization error.       var SERIALIZE_ERROR = ″serializeError″;       // Event type for a deserialization error.       var DESERIALIZE_ERROR = ″deserializeError″;       // Event type for a connect failure error.       var CONNECT_FAILURE_ERROR = ″connectFailureError″;       // Event type for an initialization error.       var INITIALIZATION_ERROR = ″initializationError″;       var CONNECT_SUCCESS = ″connectSuccess″;       In order to handle the Message 130 types for connect success and the connect failure statuses       between first Web Application 112 and Helper Service 140, we have to register a       MessageHandler with above types. The following javascript registers the listener message types       by invoking the javascript method titled “registerListenerMessageTypes( )”:       function registerListenerMessageTypes( ) {                try {                // creates a new messagehandler to store these message types                var connectHandler = new MessageHandler( );           connectHandler.addMessageType(CONNECT_FAILURE_ERROR);           connectHandler.addMessageType(CONNECT_SUCCESS);                // Maps the handleMessage to the callback of this method           // when the DCF Flex bridge triggers the handleDCFMessage(message) through external            the following handler will get triggered                connectHandler.handleMessage = handleStatus( );           }                catch (e) {                console.log(″Error in register listener: ″ + e);                }            }                    
The following code illustrates the implementation of the DCF Flex Library which is located as part of Web Application  112  using actionscript.
 
The following code implements the ConnectDCF function part of the DCF Flex Library.
 
       ConnectDCF Function Implementation 
       [0062]      
         [0000]                                package       {       import DCF.Bridge;       // connects the DCF client/ui Bridge to the native Bridge.       public function connectDCF( port : int = −1, host : String = null ) : void       {          if ( port == 0 ) port = −1;          Bridge.connect( port, host );       }       }                    
The following code implements the Bridge class part of the DCF Flex Library which is located as part of Web Application  112 . The Bridge class implementation is responsible for establishing a socket connection from DCF Flex Bridge (client) part of Web Application  112  to DCF C# Bridge (Host) part of the Helper Service  140 .
 
       Bridge Class Implementation 
       [0063]    The following code implements the IMessage interface and Message Class of type Message  130  part of the DCF Flex Library which is located as part of Web Application  112 . 
       IMessage Interface Implementation 
       [0064]      
         [0000]    
       
         
               
             
           
               
                   
               
             
             
               
                 package merapi.messages 
               
               
                 { 
               
               
                 [Bindable] 
               
               
                 // The IMessage interface describes a ‘message’ sent by the DCF bridge. 
               
               
                 public interface IMessage 
               
               
                 { 
               
               
                  // Properties 
               
               
                  // type 
               
               
                  // The message type. 
               
               
                    function get type( ) : String; 
               
               
                    function set type( val : String ) : void; 
               
               
                  // data 
               
               
                  // A generic data property. 
               
               
                    function get data( ) : Object; 
               
               
                    function set data( val : Object ) : void; 
               
               
                 } 
               
               
                 } 
               
               
                   
               
             
          
         
       
     
       Message Class Implementation 
       [0065]      
         [0000]    
       
         
               
             
           
               
                   
               
             
             
               
                 package DCF.messages 
               
               
                 { 
               
               
                 import flash.net.registerClassAlias; 
               
               
                 import DCF.Bridge; 
               
               
                 import mx.rpc.IResponder; 
               
               
                 import mx.utils.UIDUtil; 
               
               
                 // The Message class implements IMessage, a ‘message’ sent from the 
               
               
                 DCF UI layer. 
               
               
                 public class Message implements IMessage 
               
               
                 { 
               
               
                     // Needed for sending typed instances from Flash -&gt; c# as Flash 
               
               
                 doesn&#39;t parse the RemoteClass meta tag 
               
               
                     { registerClassAlias( “DCF.messages.Message”, Message ); } 
               
               
                   // Constructor. 
               
               
                     public function Message( type : String = null, data : Object = 
               
               
                     null ) : void 
               
               
                     { 
               
               
                       super( ); 
               
               
                       this.type = type; 
               
               
                       this.data = data; 
               
               
                       this.uid= UIDUtil.createUID( ); 
               
               
                     } 
               
               
                   // Properties 
               
               
                   // uid 
               
               
                   // A unique ID for the message. 
               
               
                     public var uid : String = null; 
               
               
                   // type 
               
               
                   // The type of the message. 
               
               
                     public function get type( ) : String { return    type }; 
               
               
                     public function set type( val : String ) : void {    type = val; }; 
               
               
                   // data 
               
               
                   // The data carried by this message. 
               
               
                 public function get data( ) : Object  { return    data }; 
               
               
                     public function set data( val : Object ) : void {    data = val }; 
               
               
                     // Redirects toString to the data property 
               
               
                     public function toString( ) : String 
               
               
                     { 
               
               
                       return uid + “ ” + (data != null ? data.toString( ) : “” ); 
               
               
                     } 
               
               
                     // Sends the message across the DCF bridge. 
               
               
                     public function send( responder : IResponder = null ) : void 
               
               
                     { 
               
               
                       Bridge.getInstance( ).sendMessage( this, responder ); 
               
               
                     } 
               
               
                     // Dispatchs message across on this side of the bridge. 
               
               
                     public function dispatch( ) : void 
               
               
                     { 
               
               
                       Bridge.getInstance( ).dispatchMessage( this ); 
               
               
                     } 
               
               
                   // Used by the getters/setters. 
               
               
                     private var    type : String = null; 
               
               
                     private var    data : Object = null; 
               
               
                 } 
               
               
                 } 
               
               
                   
               
             
          
         
       
     
         [0066]    The following code implements the IMessageHandler interface and MessageHandler Class to add, remove and handle messages of type Message  130 , which is part of the DCF Flex Library located as part of the Web Application  112 . 
       IMessageHandler Interface Implementation 
       [0067]      
         [0000]    
       
         
               
             
           
               
                   
               
             
             
               
                 package DCF.handlers 
               
               
                 { 
               
               
                 import DCF.messages.IMessage; 
               
               
                 // The IMessageHandler interface defines the methods for receiving a 
               
               
                 Message from the Bridge. 
               
               
                 public interface IMessageHandler 
               
               
                 { 
               
               
                    // Handles an IMessage dispatched from the Bridge. 
               
               
                    function handleMessage( message : IMessage ) : void 
               
               
                 } 
               
               
                 } 
               
               
                   
               
             
          
         
       
     
       MessageHandler Class Implementation 
       [0068]      
         [0000]                                package DCF.handlers       {       import DCF.Bridge;       import DCF.messages.IMessage;       //The IMessageHandler interface defines the methods for receiving a       Message from the Bridge.       public class MessageHandler implements IMessageHandler       {           // Automatically registers the handler for message type.           // @param type The type of message to handle.           public function MessageHandler( type : String = null ) : void           {             if ( type != null )             {                addMessageType( type );             }           }           // Handles an IMessage dispatched from the Bridge. This method       shouldbe overridden by MessageHandler sub class definitions.           public function handleMessage( message : IMessage ) : void { }           // Adds another message type to be listened for by this instance of           MessageHandler.           public function addMessageType( type : String ) : void           {             Bridge.getInstance( ).registerMessageHandler( type, this );           }           // Removes the handling of message type.           public function removeMessageType( type : String ) : void           {             Bridge.getInstance( ).unRegisterMessageHandler( type,             this );           }       }       }                    
The following code implements ConnectMessage class part of DCF Flex Library to handle connection status message types on the Web Application  112  client.
 
       ConnectMessage Class Implementation 
       [0069]      
         [0000]                                    package DCF.connect           {          import DCF.messages.Message;          public class ConnectMessage extends Message          {             public static const CONNECT_SUCCESS : String =             “connectSuccess”;             public function ConnectMessage( type : String )             {                super( type );             }          }       }                    
The following code implements the DCFErrorMessage class part of the DCF Flex Library to handle errors part of the socket connection on the web Application  112 .
 
       DCFErrorMessage Class Implementation 
       [0070]      
         [0000]                                package DCF.error       {       import flash.utils.Dictionary;       import DCF.messages.IMessage;       import DCF.messages.Message;       // The DCFErrorMessage class is a sub class of Message that is used to communicate error       messages from the Bridge       public class DCFErrorMessage extends Message       {        // Event type for a serialization error.        public static const SERIALIZE_ERROR : String = ″serializeError″;        // Event type for a deserialization error.        public static const DESERIALIZE_ERROR : String = ″deserializeError″;        // Event type for a connect failure error.        public static const CONNECT_FAILURE_ERROR : String = ″connectFailureError″;        // Event type for an initialization error.        public static const INITIALIZATION_ERROR : String = ″initializationError″;        // A map of event types -&gt; error messages          private static const ERROR_MESAGES : Dictionary = new Dictionary( );          {              ERROR_MESAGES[ SERIALIZE_ERROR ] = ″Serialize error”;              ERROR_MESAGES[ DESERIALIZE_ERROR ] = ″Deserialize error″;              ERROR_MESAGES[ CONNECT_FAILURE_ERROR ] = ″Connect Failure”;              ERROR_MESAGES[ INITIALIZATION_ERROR ] = ″Initialization Error″;          }        // Constructor.          public function DCFErrorMessage( type : String = null, message : IMessage = null ) :       void          {              super( type );              this.message    = message;          }        //The message that failed to be seriliazed, in the case of a SERIALIZE_ERROR or       DESERIALIZE_ERROR.          public var message : IMessage = null;          // Updates the value of data with the matching error message based on the message type.          override public function set type( val : String ) : void          {              super.type = val;              data   = ERROR_MESAGES[ type ].toString( );          }       }       }       package DCF.messages       {          public dynamic class DynamicMessage extends Message          {              public function DynamicMessage( )              {                 super( );              }          }       }                    
The following code implements the disconnectDCF function part of the DCF Flex Library to handle the connection close/disconnect request from the Web Application  112 .
 
disconnectDCF Function Implementation
 
         [0000]                                            package           {           import DCF.Bridge;           // Disconnects the DCF client/ui Bridge from the native Bridge.           public function disconnectDCF( ) : void           {              Bridge.disconnect( );           }           }                        
The following code implements the JavaScriptExtension class part of the DCF Flex library which is located as part of Web Application  112 . The following code registers all the actionscript methods that are exposed to JavaScript.
 
         [0000]                                package DCF       {       import flash.external.ExternalInterface;       import flash.system.Security;       import merapi.handlers.MessageHandler;       import merapi.messages.DynamicMessage;       import merapi.messages.IMessage;       // The Message class implements IMessage, a ‘message’ sent from the DCF UI layer.       public class JavaScriptExtension extends MessageHandler       {        // Constructor.          public function JavaScriptExtension( )          {             Security.loadPolicyFile( ‘xmlsocket://’ + Bridge.HOST + ‘:12364’ );             Bridge.getInstance( );             ExternalInterface.addCallback( “registerMessageHandler”,       registerMessageHandler );             ExternalInterface.addCallback( “unRegisterMessageHandler”,       unRegisterMessageHandler );             ExternalInterface.addCallback( “sendMessage”, sendMessage );             ExternalInterface.addCallback( “dispatchMessage”, dispatchMessage );             ExternalInterface.addCallback( “connectDCF”, connectDCF );             ExternalInterface.addCallback( “disconnectDCF”, disconnectDCF );             ExternalInterface.addCallback( “systemExecute”, systemExecute );                handler = new JavaScriptHandler( );          }          private function alert( o : Object ) : void          {             ExternalInterface.call( “alert”, o );          }        public function registerMessageHandler( type : * ) : void        {              handler.removeMessageType( type );              handler.addMessageType( type );        }        public function unRegisterMessageHandler( type : * ) : void        {              handler.removeMessageType( type );        }        public function sendMessage( message : * ) : void        {           var m : DynamicMessage = new DynamicMessage( );           for ( var propName : String in message )           {             if ( !( m[ propName ] is Function ) )             {                 m[ propName ] = message[ propName ];             }           }           m.send( );        }        public function dispatchMessage( message : * ) : void        {           var m : DynamicMessage = new DynamicMessage( );           for ( var propName : String in message )           {             if ( !( m[ propName ] is Function ) )             {                 m[ propName ] = message[ propName ];             }           }           Bridge.getInstance( ).dispatchMessage( m );        }        protected var    handler : JavaScriptHandler = null;       }       }       import DCF.handlers.MessageHandler;       import DCF.messages.IMessage;       import flash.external.ExternalInterface;       class JavaScriptHandler extends MessageHandler       {           override public function handleMessage( message : IMessage ) : void           {             ExternalInterface.call( “handleDCFMessage”, message );           }       }                    
The above code may be used to implement the client DCF Flex Bridge, which enables the connection between Web Application  112  and Helper Service  140 . When the JavaScript from the HTML DOM executes connectRADCF part of Web Application  112  that invokes bridge.connectDCF method of DCF Flex Library part of Web Application  112  which is available through actionscript&#39;s externalinterface. Now the DCF Flex Library part of Web Application  112  establishes a socket connection on the specified port with the DCF C# Library part of Helper Service  140 . Once the connection is successfully established between the Web Application  112  and the Helper Service  140 , the Web Application  112  proceeds with further work flow process depends on the requirements that application needs to satisfy.
 
         [0071]    The following code is customized to the workflow process or requirements or intended purpose of the figures attached. The following workflow process tracks along with  FIG. 6 , the purpose of which is to allow a Web Application  112  running on a first computing device  110  with Helper Service  140  installed to communicate to a second computing device  120 , which in this example is an android device. 
       Step  1 : Message Creation  114  by Web Application  112  on Computing Device  110   
       [0072]    Before the step of Message Creation  114  in this example, Web Application  112  registers required Message Types with the DCF Flex Bridge Instance part of Web Application  112  using the MessageHandler&#39;s AddMessageType illustrated in the JavaScript MessageHandler Prototype implementation. 
         [0000]    
       
         
               
             
           
               
                   
               
             
             
               
                 //code to register the Message Types for this process 
               
               
                 function registerRaVtDeviceInterpreterMessageTypes( ) { 
               
               
                  var connectHandler = new MessageHandler( ); 
               
               
                  connectHandler.addMessageType(RaVt_INTERPRETER_MESSAGE_HANDLER); 
               
               
                  connectHandler.handleMessage = responsefromDevice(message); 
               
               
                 } 
               
               
                    The next step is Message Creation 114. The following code creates the message 130 to 
               
               
                 request to connect to external Android device 120 and sends that to the Android Device 120 
               
               
                 through the established connection between Web Application 112 and Helper Service 140. 
               
               
                 function sendMessage( ) { 
               
               
                 //message (130) 
               
               
                  var message = new Message( ); 
               
               
                 //specifies the registerd message type, which in this case acts as target 
               
               
                  message.type (136) = RaVt_INTERPRETER_MESSAGE_HANDLER; 
               
               
                 //specifies the data object or string or constant or any arbitrary value 
               
               
                 Var Data = 
               
               
                 ‘{″Command″:″DEVICE_CONNECT_REQUEST″,″Mode″:″REQUEST″,″Count″:1,″HasData″: 
               
               
                 true,″Data″:{″Serial″:″015D941A0B01E02B″,″Path″:″C:\\ProgramData\\RaVt\\Install\\RaVtAndroid 
               
               
                 Support.apk″},″HasError″:false,″Error″:{ }}’; 
               
               
                  message.data (134) = Data; 
               
               
                 //invokes the javascript prototype send method illustrated below 
               
               
                  message.send( ); 
               
               
                 //message id (132) is auto-generated in the DCF Flex library 
               
               
                 } 
               
               
                 //The following method invokes the DCF Flex library sendMessage through external interface 
               
               
                 Message.prototype.send = function( ) 
               
               
                 { 
               
               
                    bridge.sendMessage( this ); 
               
               
                 } 
               
               
                 //DCF Flex Library sendMessage implementation which serializes the message using AMF and 
               
               
                 writes the message on the socket 
               
               
                 public function sendMessage( message : IMessage, responder : IResponder=null ) : void 
               
               
                  { 
               
               
                   // Try to serialize the message using AMF    writer. 
               
               
                    var bytes : ByteArray =    writer.write( message ); 
               
               
                   // Write the message on the socket and flush the packets. 
               
               
                       client.writeBytes( bytes ); 
               
               
                       client.flush( ); 
               
               
                 } 
               
               
                 //DCF C# Library&#39;s BridgeListenerThread reads data from the input stream of the accepted client 
               
               
                 socket connection as below and dispatches the message using Bridge Instance DispatchMessage 
               
               
                 as illustrated below 
               
               
                 public void Run( ) 
               
               
                 { 
               
               
                 // reads all the bytes from the input stream, check the illustrated for details, uses the AMF reader 
               
               
                     reader.read(bytes); 
               
               
                 // Broadcast the Message from the Bridge 
               
               
                  Bridge.GetInstance( ).DispatchMessage( message ); 
               
               
                 } 
               
               
                 public void DispatchMessage( IMessage message ) 
               
               
                 { 
               
               
                 // Checks to see if there is any handlers registered by helper services for this message type 
               
               
                 “RaVt_INTERPRETER_MESSAGE_HANDLER” 
               
               
                    if (    handlers.ContainsKey(message.type) == false ) 
               
               
                    { 
               
               
                     return; 
               
               
                    } 
               
               
                    else 
               
               
                    { 
               
               
                 // if it finds list of handlers for this message type then it invokes each handler&#39;s HandleMessage 
               
               
                 which is overrided in the ListenerMessageHandler 
               
               
                     list =    handlers[message.type]; 
               
               
                     if ((list != null) &amp;&amp; (list.Count &gt; 0)) 
               
               
                     { 
               
               
                      foreach (IMessageHandler handler in list) 
               
               
                      { 
               
               
                       handler.HandleMessage(message); 
               
               
                      } 
               
               
                     } 
               
               
                     } 
               
               
                 } 
               
               
                 //DCF C# Helper Service&#39;s ListenerMessageHandler handles the message type using the 
               
               
                 overridden HandleMessage Method. 
               
               
                 public ListenerMessageHandler( ) 
               
               
                 { 
               
               
                 AddMessageType(RaVt_INTERPRETER_MESSAGE_HANDLER); 
               
               
                 } 
               
               
                 //handling the message type to fulfill the requirements or workflow process 
               
               
                 public override void HandleMessage( IMessage message ) 
               
               
                 { 
               
               
                 if ( message.type.Equals(RaVt_INTERPRETER_MESSAGE_HANDLER) ) 
               
               
                   { 
               
               
                       //customized method to do the required actions or execution 
               
               
                    HandleInterPreterMessage(message); 
               
               
                   } 
               
               
                 } 
               
               
                   
               
             
          
         
       
     
         [0073]    As enabled by the code shown above, the device agnostic message  130  created by the Web Application  112  has now reached Helper Service  140 . The Helper Service  140  now passes the device agnostic message  130  to Android Device  120 , which contains the native android application  122 . 
         [0074]    In order to send the message to the android device  120 , a device interpreter class part of Helper Service  140  is implemented, which can be a customized class for any action that needed to fulfill the device agnostic message  130 . 
         [0000]    
       
         
               
             
           
               
                   
               
             
             
               
                 //Implementation of a wrapper class for DeviceInterpreter API 
               
               
                 class RaVtDeviceInterpreterWrapper 
               
               
                 { 
               
               
                    //deviceinterpreter API class 
               
               
                   private DeviceInterpreter deviceInterpreter = null; 
               
               
                    //deviceinterpreterlistener class 
               
               
                   private DeviceInterpreterListener deviceInterpreterListener = null; 
               
               
                   public RaVtDeviceInterpreterWrapper( ) 
               
               
                   { 
               
               
                    deviceInterpreterListener = new DeviceInterpreterListener( ); 
               
               
                     deviceInterpreter = new 
               
               
                     DeviceInterpreter(deviceInterpreterListener); 
               
               
                     deviceInterpreter.initialize(deviceDetails.ToString( )); 
               
               
                   } 
               
               
                    // sends the message to the device using the deviceInterpreter API 
               
               
                   public void sendClientMessageToADB(string jsondata) 
               
               
                   { 
               
               
                    deviceInterpreter.sendRequest(RequestID, jsondata); 
               
               
                   } 
               
               
                  } 
               
               
                   
               
             
          
         
       
     
         [0075]    The following code receives the response message  126  or callback  124  from the Android Device  120  which is then packaged as device agnostic message  130  and sent back to the web Application  112  from the Helper Service  140  using the established socket connection. 
         [0000]    
       
         
               
             
           
               
                   
               
             
             
               
                 //Device Interpreter Listener class responsible to handle the callback from 
               
               
                 the device which sends messages or responses back through device 
               
               
                 interpreter 
               
               
                  public class DeviceInterpreterListener : IDeviceInterpreter 
               
               
                  { 
               
               
                    // handles the Message or Callback from Android Application (122) 
               
               
                   public void MessageCallback(string responseid, string responsemsg) 
               
               
                   { 
               
               
                       //message (126) generated from android application(122) 
               
               
                 part of the Android device (120) 
               
               
                    Message m = new Message( ); 
               
               
                       //type which acts as target 
               
               
                    m.type = RaVt_INTERPRETER_MESSAGE_HANDLER; 
               
               
                       //response data back to web application 
               
               
                    m.data = respmsg; 
               
               
                       //send invokes the DCF C# library&#39;s send method of the 
               
               
                 Message class illustrated earlier 
               
               
                    m.send( ); 
               
               
                   } 
               
               
                  } 
               
               
                 //Message class send method 
               
               
                  public void send( ) 
               
               
                  { 
               
               
                    //invokes the bridge sendMessage to send the message across the 
               
               
                 bridge through the socket connection 
               
               
                    Bridge.GetInstance( ).SendMessage( this ); 
               
               
                  } 
               
               
                 //following method part of DCF C# library Bridge.cs class 
               
               
                 public void SendMessage( IMessage message ) 
               
               
                   { 
               
               
                       // Serializes the message using AMT Writer 
               
               
                         byte[ ] bytes =    writer.write( message ); 
               
               
                    // Send the length of the message first 
               
               
                    byte[ ] lenBytes = new byte[4]; 
               
               
                    lenBytes[0] = (byte)(bytes.Length &gt;&gt; 24); 
               
               
                    lenBytes[1] = (byte)(bytes.Length &gt;&gt; 16); 
               
               
                    lenBytes[2] = (byte)(bytes.Length &gt;&gt; 8); 
               
               
                    lenBytes[3] = (byte)bytes.Length; 
               
               
                    //send the header 
               
               
                       client.Send(lenBytes); 
               
               
                       client.Send(bytes); 
               
               
                      } 
               
               
                 //DCF Flex Library handleReciveSocketData reads all the input stream 
               
               
                 private function handleReceiveSocketData( event : ProgressEvent ) : void 
               
               
                 { 
               
               
                    var messages : Array =    reader.read(    byteBuffer ).reverse( ); 
               
               
                 // decodes the message to of type Message (130). 
               
               
                    var message : IMessage = null; 
               
               
                    var decoded : Object = messages.pop( ); 
               
               
                    message = decoded as IMessage; 
               
               
                 // Dispatchs the message to registered IMessageHandlers 
               
               
                    dispatchMessage( message ); 
               
               
                 } 
               
               
                   
               
             
          
         
       
     
         [0076]    The following code dispatches the message from DCF C# Library part of Helper Service  140  to the JavaScript part of the Web Application  112  using the handleDCFMessage externalinterface implementation. 
         [0000]    
       
         
               
             
           
               
                   
               
             
             
               
                 public function dispatchMessage( message : IMessage ) : void 
               
               
                 { 
               
               
                 // Get the list of handlers registered for the 
               
               
                 RaVt_INTERPRETER_MESSAGE_HANDLER message type 
               
               
                   var list : Array =    handlers[ message.type ] as Array; 
               
               
                   // invokes the handleMessage of the registered Messagehandlers 
               
               
                   handler.handleMessage( message ); 
               
               
                 } 
               
               
                 // The handleMessage class invokes the overrided method of the 
               
               
                 JavaScriptHandler class. 
               
               
                 override public function handleMessage( message : IMessage ) : void 
               
               
                 { 
               
               
                 //invokes the handleDCFMessage JavaScript method part of the web 
               
               
                 application. 
               
               
                 ExternalInterface.call( “handleDCFMessage”, message ); 
               
               
                 } 
               
               
                   
               
             
          
         
       
     
         [0077]    The handleDCFMessage method of the Web Application  112  as illustrated below invokes the respective handler methods or actions mapped to handlersMap array part of javascript implementation part of Web Application  112  based on the message target  136 . 
         [0000]                                function handleDCFMessage(message) {          // The list of handlers registered for messsage.type          var list = handlersMap[ message.type ];          // since we have the connectHandler registered for this message          type          //it invokes the connectHandler handleMessage which invokes the          responsefromdevice( )          connectHandler.handleMessage( message );       }       function responsefromDevice(message) {          // the message (126) from the device reached the web application          using the DCF bridge       //specifies the data object or string or constant or any arbitrary value        Var Respmsg = message.data (134);          //sample response message       Respmsg:       “{″Command″:″DEVICE_CONNECT_REQUEST″,″Data″:{″Serial″:       ″015D941A0B01E02B″,″Approved″:true,″Path″:″C:\\ProgramData\\       RaVt\\Install\\RaVtAndroidSupport.apk″},″HasData″:true,″Count″:1,       ″HasError″:false,″Mode″:″RESPONSE″}”       }                    
Thus, this example code demonstrates how a device agnostic message  130  begun by creating a message  114  from Web Application  112  on the first computing device  110  through the use of the Helper Service  140 , the message  130  then being passed to the android device  120  containing the native android application  122 . The android application  122  can execute instructions based upon the data of the message, and further respond by creating a message  126  or callback  124  with instructions to Web Application  112 .
 
         [0078]    A further variant of the present invention is shown in  FIG. 8 . In this preferred embodiment, the communication system  200  of the preset invention comprises a first computing device  210 , a second computing device  220  and a third, intermediary computing device  230 . In this embodiment of the present invention, the intermediary computing device  230  could comprise a cloud based device communications framework which enables communication between the first computing device  210  and the second computing device. For instance, the address component  236  of an initial device agnostic message from a first computing device (e.g., a desktop) to a second computing device (e.g., a smartphone) might lack the socket address of the second computing device and instead have only the phone number of the target smartphone, but the cloud computing intermediary computing device could use, for instance, a database (not shown) to look up the IP address of the smart phone to facilitate the ongoing communication and control abilities as described above. Likewise, the features of certain other embodiments could be combined within the bounds of this embodiment. For instance, the use of intent  236  could be employed to permit a first device to send out communications which would be interpreted and acted upon only by a subset of applications from a group of remote mobile computing devices such as second computing device  220 . A specific embodiment of this implementation is where a multiple users walk into a store, and the store operator is periodically generating generic messages to be received and acted upon by responsive mobile computing devices, e.g., a phone store polling phones for diagnostic information of customers coming into the store to permit better support. 
         [0079]    The above description is not intended to limit the meaning of the words used in the following claims that define the invention. Rather, it is contemplated that future modifications in structure, function or result will exist that are not substantial changes and that all such insubstantial changes in what is claimed are intended to be covered by the claims. For instance, the references to web browsers and presentation applications as shown in certain preferred embodiments of present invention are for illustrative purposes with reference to the example drawings only. Likewise, it will be appreciated by those skilled in the art that various changes, additions, omissions, and modifications can be made to the illustrated embodiments without departing from the spirit of the present invention. All such modifications and changes are intended to be covered by the following claims.