Protocols/MSNP/Activities/SDK/Techref/Developing/Devmulti: Difference between revisions
Animadoria (talk | contribs) (Created automatically by Anima Importer) |
Animadoria (talk | contribs) (Created automatically by Anima Importer) |
||
Line 1: | Line 1: | ||
<!-- Generated @ 08/12/2022 23: | <!-- Generated @ 08/12/2022 23:36:17 +01:00 using Anima's CHM converter based on techref/developing/devmulti.htm --> | ||
{{Protocols/MSNP|section=Activities}} | {{Protocols/MSNP|section=Activities}} | ||
__NOTOC__= Multiuser Application = | __NOTOC__= Multiuser Application = | ||
Line 38: | Line 38: | ||
The method <span class="clsMethod">Channel.SendFile</span> can be used to transfer files. If used, the application must also have an event handler for <span class="clsEvent">Channel.OnFileReceived</span>. | The method <span class="clsMethod">Channel.SendFile</span> can be used to transfer files. If used, the application must also have an event handler for <span class="clsEvent">Channel.OnFileReceived</span>. | ||
Special permissions are required for using the instant message and file transfer features. For more information on permissions, see [[ | Special permissions are required for using the instant message and file transfer features. For more information on permissions, see [[Protocols/MSNP/Activities/SDK/Sandbox|Standard vs. Advanced Applications]]. | ||
An application should have an event handler called <span class="clsEvent">Channel.OnRemoteAppClosed</span>. After this event fires, the connection is closed. Any method that tries to send data to a closed connection will throw an exception. | An application should have an event handler called <span class="clsEvent">Channel.OnRemoteAppClosed</span>. After this event fires, the connection is closed. Any method that tries to send data to a closed connection will throw an exception. |
Revision as of 22:36, 12 August 2022
Multiuser Application
A multiuser application requires synchronization between two clients and must use event handlers to react to connection- and data-related events.
The following processes make up the foundation of a multiuser MSN® Messenger Activity:
- Synchronizing
- Sending and receiving data
- Error handling
Synchronizing
After an invitation to run an Activity has been sent and accepted, both Messenger clients load the application. The application that loads first must wait until the other application sends the signal that it is ready to communicate.
Here is an example order of events:
The first application to load calls Channel.Initialize, and then waits for the event Channel.OnRemoteAppLoaded to fire. The second application calls Channel.Initialize when it is ready to communicate, and the event Channel.OnRemoteAppLoaded fires immediately.
If the remote user cannot load the application, then the event Channel.OnRemoteAppLoaded will never fire back to the first application. You can set a timer to display a message after a certain interval, so the application does not appear to be frozen.
When a computer's Internet security level is set to High, scripting is disabled, and MSN Messenger Activities will not run.
Sending and Receiving Data
The primary way to send information is by the method Channel.SendData. An application must have an event handler called Channel.OnDataReceived; this event fires when the application receives data.
The methods Channel.SendIM and Channel.SendIMAsUser can be used to send instant messages. If used, the application must also have an event handler for Channel.OnIMReceived.
The method Channel.SendFile can be used to transfer files. If used, the application must also have an event handler for Channel.OnFileReceived.
Special permissions are required for using the instant message and file transfer features. For more information on permissions, see Standard vs. Advanced Applications.
An application should have an event handler called Channel.OnRemoteAppClosed. After this event fires, the connection is closed. Any method that tries to send data to a closed connection will throw an exception.
Error Handling
An application should have an event handler for Channel.OnDataError. This event fires if Channel.SendData fails. Channel.OnDataError contains variables that, if used, display the type of error and provide a copy of the data. Typically, an application should try to send the data again, in case the error was an isolated communication problem.
Applications should also employ other error handling techniques, such as wrapping any method that sends instant messages in an error handling block. These could include a try-catch block in JavaScript or an ON ERROR GOTO statement in Microsoft® Visual Basic® Scripting Edition (VBScript).