Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/palkan/as3_p2plocal
as3 lib for local p2p connections (serverless rtmfp)
https://github.com/palkan/as3_p2plocal
Last synced: about 1 month ago
JSON representation
as3 lib for local p2p connections (serverless rtmfp)
- Host: GitHub
- URL: https://github.com/palkan/as3_p2plocal
- Owner: palkan
- License: mit
- Created: 2013-08-23T10:38:15.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-05-07T16:33:22.000Z (over 6 years ago)
- Last Synced: 2024-12-03T04:16:09.984Z (about 1 month ago)
- Language: ActionScript
- Size: 329 KB
- Stars: 25
- Watchers: 11
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-actionscript-sorted - as3_p2plocal - as3 lib for local p2p connections (serverless rtmfp) (Networking / P2P)
README
AS3 local RTMFP connections library
----------### Features:
* Create new local net group with just one call using config Object
* Message types
* Direct routing (peer-to-peer send message)
* Automatically restore session state (if there is at least one another peer in the group)Examples: [http://palkan.github.io/as3_p2plocal/examples/index.html](http://palkan.github.io/as3_p2plocal/examples/index.html)
### Usage
```actionscript
// ---------- init ------------//
p2p_client = new P2PClient(); //create new instance
p2p_client.addEventListener(P2PEvent.CONNECTED, onConnect); // add listener for 'connect' event: it means connection established and you are connected to NetGroup; if you don't need to restore a state - that's enough
p2p_client.addEventListener(P2PEvent.STATE_RESTORED, onStateRestored); // add listener for 'state_restored' event: it means all previously dispatched messages within the group has been received and ready to be parsed;p2p_client.listen(messageReceived, "message"); // add listener for messages of a type "message"
p2p_client.connect(new P2PConfig({
groupName: "example", // NetGroup name
saveState: "true" // restore state from previous messages
}));//------------- state restored ---------//
function onStateRestored(e:P2PEvent):void {
// e.info.state contains an Array of messages
}//------------ receive messages --------//
function messageReceived(p:P2PPacket):void{
// handle message; p.data contains data was sent
}//------------ send messages ----------//
p2p_client.send(data, type(="default"), system (=true), recipient(="");
```