What is it?
28 |This project expose Rtmfp protocol (provided by Flash version 10) to javascript application throught a hidden flash applet. 29 | The protocol allow multiple clients to communicate directly. See the references for more details about the protocol.
30 |Possible uses include:
31 |-
32 |
- Game 33 |
- Real-time communication 34 |
- High bandwith communication 35 |
- Chat application 36 |
How to use it
39 |40 | Initialisation:
41 |
42 | var config = {
43 | DEBUG:false, //Internal debug of the Flash applet will be output to console.info
44 | rtmfpUrl:'rtmfp://p2p.rtmfp.net/API_KEY'}; //Rtmfp server
45 |
46 | //Functions to handle the various events
47 | var callbacks = {
48 | onPeerIdRecvCall: onPeerIdRecv,
49 | onMessageRecvCall: onMessageRecv,
50 | onPeerConnectCall: onPeerConnect,
51 | onPeerDisconnectCall: onPeerDisonnect};
52 |
53 | rtmfp = new Rtmfp("../../bin/rtmfp.swf",config,callbacks);
54 |
55 |
56 | Define the different callbacks:
57 |
58 | onPeerIdRecv = function(peerId) {
59 | ...
60 | }
61 | onMessageRecv = function(peerId,cmd,object) {
62 | ...
63 | }
64 | onPeerConnect = function(peerId) {
65 | ...
66 | return true; //If the incoming connection is accept
67 | }
68 | onPeerDisconnect = function(peerId) {
69 | ...
70 | }
71 |
72 |
73 | Use the main instance (Rtmfp object) to connect to peer and send message. 74 | The main principe of Rtmfp communication is that you can only send message 75 | to those who are connected to you.
76 |
77 | //Once connected messages can be _received_ from this peer
78 | rtmfp.connectToPeer("6487b[...]");
79 |
80 | //Publish message to all connected peers
81 | //The data passed can be any serializable js object
82 | rtmfp.send("NICKNAME","bob");
83 | rtmfp.send("LIST_ITEMS",["1","2","3","4"]);
84 |
85 |
86 | Demos
87 | 88 |-
89 |
- Chat 90 |
References
93 | Rtmfp documentation94 |
-
95 |
- Adobe website (include a link to register for api key) 96 |
- Future of communication with RTMFP by Matthew Kaufman 97 |
- P2P on the Flash Platform with RTMFP 98 |
100 |
-
101 |
- NetStream reference documentation 102 |
104 |
-
105 |
- JQuery 106 |
- JQuery-json 107 |
- Swfobject 108 |