Presentation is loading. Please wait.

Presentation is loading. Please wait.

AG Retreat 2006 – Hands-On Session Developing Shared Applications Susanne Lefvert University of Chicago.

Similar presentations


Presentation on theme: "AG Retreat 2006 – Hands-On Session Developing Shared Applications Susanne Lefvert University of Chicago."— Presentation transcript:

1 AG Retreat 2006 – Hands-On Session Developing Shared Applications Susanne Lefvert lefvert@mcs.anl.gov University of Chicago

2 AG Retreat 2006 – Hands-On Session Shared Applications Allows individuals to use programs together from remote locations Shared Browser –Browse the web together Shared Presentation –View and control remote presentations Shared VNC –Secured screen sharing And many more…

3 AG Retreat 2006 – Hands-On Session Shared Applications

4 AG Retreat 2006 – Hands-On Session Outline Characteristics –Sharing State –Event Communication Developer Tools –SharedAppClient –DatastoreClient –Access Grid Package Manager Example: Shared PDF Exercises Documentation

5 AG Retreat 2006 – Hands-On Session Sharing State Venue foo Client 1 Client 2 Client 3 * Communicating via ZSI SOAP calls Application Session State: foo

6 AG Retreat 2006 – Hands-On Session foo bar foo Event Communication bar Client 1 Client 2 Client 3 * Event communication using Twisted Venue Event Channel Application Session Event Channel

7 AG Retreat 2006 – Hands-On Session Venue SharedAppClient Your Application SharedAppClient SharedApplicationIW Application Session Event Channel EventClient

8 AG Retreat 2006 – Hands-On Session SharedAppClient http://www.mcs.anl.gov/fl/research/accessgrid/documentation/developer/api/ Tool for developers that includes: –SOAP communication –Event exchange –Logging –Data cache –Exception handling API –AccessGrid.SharedAppClient

9 AG Retreat 2006 – Hands-On Session SharedAppClient API: Join() – Connect to an application session InitLogging() – Get object for logging Shutdown() – Shut down soap interface and event client SendEvent() – Distribute an event to all clients RegisterEventCallback() – Register callback for event SetData() – Set shared state GetData() – Get shared state UpdateDataCache() – Update cached data GetPublicId() – Get my unique id GetVenueURL() – Get venue url

10 AG Retreat 2006 – Hands-On Session DatastoreClient API: LoadData() – Get data from venue QueryMatchingFiles() – Get file names matching pattern GetFileData() – Get data description for a file Download() – Download file from venue Upload() – Upload file to venue RemoveFile() – Remove file from venue

11 AG Retreat 2006 – Hands-On Session 1.Create an application description file: MySharedApp.app 2.Build an Access Grid package: SharedAppName.agpkg3 3.Use agpm3.py to install the application –agpm3.py –help –Open the package in the Venue Client 4.Start the application session in the Venue Client Packaging and Installation [application] name = SharedMyApp mimetype = application/x-ag-shared-myapp extension = sharedmyapp files = SharedMyApp.py, otherFile [commands] Open = %(python)s SharedMyApp.py -a %(appUrl)s

12 AG Retreat 2006 – Hands-On Session Example: Shared PDF

13 AG Retreat 2006 – Hands-On Session Example: Shared PDF SharedAppClient # Create shared application client self.sharedAppClient = SharedAppClient(name) self.log = self.sharedAppClient.InitLogging() # Get client profile clientProfile = ClientProfile(UserConfig.instance().GetProfile()) # Join the application session self.sharedAppClient.Join(appUrl, clientProfile) self.id = self.sharedAppClient.GetPublicId() # Register callbacks for external events self.sharedAppClient.RegisterEventCallback("openFile", self.OpenCallback) self.sharedAppClient.RegisterEventCallback(“changePage", self.ChangePageCallback)

14 AG Retreat 2006 – Hands-On Session Example: Shared PDF Get Current State State: URL to file and current page number # Get current state self.file = self.sharedAppClient.GetData(“file") self.pageNr = self.sharedAppClient.GetData(“page") if self.file: try: self.dataStoreClient.Download(self.file, "tmp") self.pdf.LoadFile("tmp") self.pdf.setCurrentPage(self.pageNr) except: self.log.exception("PdfViewer.__init__: Download failed %s"%(self.file))

15 AG Retreat 2006 – Hands-On Session Example: Shared PDF

16 AG Retreat 2006 – Hands-On Session Example: Shared PDF Event Communication # -- sender --- def OnNextPageButton(self, event): '''Invoked when user clicks the next button.''' self.pageNr = self.pageNr + 1 self.pdf.setCurrentPage(self.pageNr) self.sharedAppClient.SendEvent(“changePage", self.pageNr) self.sharedAppClient.SetData("page", self.pageNr) # --- receiver --- def ChangePageCallback(self, event): ''' Invoked when a changePage event is received.''' self.pageNr = event.data id = event.GetSenderId() # Ignore my own events if self.id != id: wxCallAfter(self.pdf.setCurrentPage, self.pageNr) Event: type – “changePage”, data – page number

17 AG Retreat 2006 – Hands-On Session Example: Shared PDF

18 AG Retreat 2006 – Hands-On Session Example: Shared PDF DatastoreClient def PopulateCombobox(self, default = None): # Get pdf files from venue fileNames = [] wxBeginBusyCursor() try: self.dataStoreClient.LoadData() fileNames = self.dataStoreClient.QueryMatchingFiles("*.pdf") except: self.log.exception("FileSelectorDialog.PopulateCombobox: Failed.") wxEndBusyCursor() # Update combobox self.pdfList.Clear() for file in fileNames: self.pdfList.Append(file)

19 AG Retreat 2006 – Hands-On Session Example: Shared PDF Packaging and Installation 1. Create SharedPDF.app: 2. SharedPDF.py + SharedPDF.app => SharedPDF.agpkg3 (zip package) 3. agpm3.py --p SharedPDF.agpkg3 [application] name = Shared PDF mimetype = application/x-ag-shared-pdf extension = sharedpdf files = SharedPDF.py [commands] Open = %(python)s SharedPDF.py -v %(venueUrl)s -a %(appUrl)s

20 AG Retreat 2006 – Hands-On Session Starting Application Session

21 AG Retreat 2006 – Hands-On Session AGTk 2.4 – 3.0 Migration 1.Connection id needed for venue data store; the id can be retrieved via the.app file. 2.Twisted-wxPython interaction; add reactor imports and reactor.interleave(wxCallAfter). 3.More restrictive rules on data format for events; only primitive data types allowed. 4.Data received from the application service when using the method sharedAppClient.GetData() may be unicode; convert received data to correct python type. 5.Use the new event method event.GetSenderId() to retrieve the public id of a sender. 6.An application package should have extension agpkg3. http://www.mcs.anl.gov/fl/research/accessgrid/documentation/MigrationGuides/ SharedApplicationsMigrationGuide.htm

22 AG Retreat 2006 – Hands-On Session Exercises Exercise 1: Shared Stoplight Exercise 2: Shared Group Chat exercise http://www.mcs.anl.gov/fl/research/accessgrid/documentation/tutorial/Retreat 2006/SharedApps/

23 AG Retreat 2006 – Hands-On Session Exercise 1: Shared Stoplight

24 AG Retreat 2006 – Hands-On Session Exercise 1: Shared Stoplight Three Tasks: 1.Create an AG package, install, and start the application from the Venue Client. 2.Add a new button – yellow 3.Add a text field to change the title

25 AG Retreat 2006 – Hands-On Session Exercise 1: Shared Stoplight

26 AG Retreat 2006 – Hands-On Session Exercise 2: Shared Group Chat

27 AG Retreat 2006 – Hands-On Session Documentation Reference Materials http://www.mcs.anl.gov/fl/research/accessgrid/documentation/developer.html Toolkit API http://www.mcs.anl.gov/fl/research/accessgrid/documentation/developer/api/ AGTk 2-3 Migration Guide http://www.mcs.anl.gov/fl/research/accessgrid/documentation/MigrationGuides/ SharedApplicationsMigrationGuide.htm


Download ppt "AG Retreat 2006 – Hands-On Session Developing Shared Applications Susanne Lefvert University of Chicago."

Similar presentations


Ads by Google