Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Richard-Walton/TwoWayLocalConnection
Two way, asynchronous, LocalConnection class which is not subject to the 40KB message size limit imposed by the standard actionscript LocalConnection class
https://github.com/Richard-Walton/TwoWayLocalConnection
Last synced: 3 months ago
JSON representation
Two way, asynchronous, LocalConnection class which is not subject to the 40KB message size limit imposed by the standard actionscript LocalConnection class
- Host: GitHub
- URL: https://github.com/Richard-Walton/TwoWayLocalConnection
- Owner: Richard-Walton
- Created: 2012-04-11T17:08:40.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2016-07-12T23:45:31.000Z (over 8 years ago)
- Last Synced: 2024-06-23T20:43:00.161Z (5 months ago)
- Language: ActionScript
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-actionscript-sorted - TwoWayLocalConnection - Two way, asynchronous, LocalConnection class which is not subject to the 40KB message size limit imposed by the standard actionscript LocalConnection class (Utilities / Asynchronous)
README
This project extends the actionscript LocalConnection class to add the ability to make to make asynchronous function calls between two connected clients. Additionally, messages sent between two connected clients are not subject to the 40KB limit imposed by the standard LocalConnection class:
Example:
```
package
{
import com.dubitplatform.localConnection.LocalConnectionService;
import flash.events.StatusEvent;
import mx.events.PropertyChangeEvent;
import mx.rpc.AsyncToken;public class LocalConnectionTest
{
private var localConnectionSerivce:LocalConnectionService;
public function LocalConnectionTest()
{
/* Instanciate new LocalConnectionService and provide the 'client' object which contains functions which
are available to be called by a remote client */
localConnectionSerivce = new LocalConnectionService(this);
/* Listen for status events from the service - Specifically the "Connected" event. Possible status events
dispatched are:
"idle" - Nothing is happening
"connecting" - The service is trying to establish a connection
"waitingForRemoteClient" - The service is waiting for a remote client to connect
"connected" - A remote client has connected
"timedOut" - The remote client has timed out
"closing" - The service is disconnecting
*/
localConnectionSerivce.addEventListener(StatusEvent.STATUS, function(e:StatusEvent) : void
{
if(e.code == LocalConnectionService.CONNECTED) callRemoteFunction();
});
// Start the service
localConnectionSerivce.connect("localConnectionTest");
}
private function callRemoteFunction() : void
{
/* When calling a function on the remoteClient an asyncToken is returned. When the clients reponse is recieved
this token will be notified - Here we are calling the "timesByTwo" function on the remote client */
var asyncToken:AsyncToken = localConnectionSerivce.remoteClient.timesByTwo(42);
// Add listener which will be notified when a response has been recieved
asyncToken.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, function(e:PropertyChangeEvent) : void
{
trace(e.newValue); // Traces out 84
});
}
// This public function is available to a remote client
public function timesByTwo(input:int) : int
{
return input * 2;
}
}
}
```