• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8. Shared Objects > Broadcasting Remote Method Callswith send( )

8.10. Broadcasting Remote Method Callswith send( )

When data changes in one copy of a shared object, that data is copied to every other copy of the shared object, after which every shared object's onSync( ) method is called. Shared objects provide another way to broadcast information to every copy of a shared object without storing data or calling the onSync( ) method. Custom methods of the shared object can be defined so that they can be executed and passed data. For example, a custom showMessage( ) method can be defined that will show text passed to it within a text field. One copy of a shared object can then send some text to every copy of the shared object and ask that the text be processed by the method named showMessage( ). Asking remote shared objects to execute a method is one mechanism of remote method invocation (RMI); see Chapter 9 for more information on RMI.

A request to invoke a method will succeed only on the shared objects that define a method with that name. Requests to invoke a method are made using SharedObject.send( ). A common use for send( ) is to broadcast the text messages that show up in a chat component. As an oversimplified example, if this statement is executed:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint