What is it?

This project expose Rtmfp protocol (provided by Flash version 10) to javascript application throught a hidden flash applet. The protocol allow multiple clients to communicate directly. See the references for more details about the protocol.

Possible uses include:

How to use it

Initialisation:

    var config = {
		DEBUG:false, //Internal debug of the Flash applet will be output to console.info
		rtmfpUrl:'rtmfp://p2p.rtmfp.net/API_KEY'}; //Rtmfp server
	
	//Functions to handle the various events
	var callbacks = {
		onPeerIdRecvCall:     onPeerIdRecv, 
		onMessageRecvCall:    onMessageRecv,
		onPeerConnectCall:    onPeerConnect,
		onPeerDisconnectCall: onPeerDisonnect};
	
	rtmfp = new Rtmfp("../../bin/rtmfp.swf",config,callbacks);
    

Define the different callbacks:

    onPeerIdRecv = function(peerId) {
	    ...
    }
    onMessageRecv = function(peerId,cmd,object) {
	    ...
    }
    onPeerConnect = function(peerId) {
	    ...
	    return true; //If the incoming connection is accept
    }
    onPeerDisconnect = function(peerId) {
	    ...
    }
    

Use the main instance (Rtmfp object) to connect to peer and send message. The main principe of Rtmfp communication is that you can only send message to those who are connected to you.

     //Once connected messages can be _received_ from this peer
    rtmfp.connectToPeer("6487b[...]");
    
    //Publish message to all connected peers
    //The data passed can be any serializable js object
    rtmfp.send("NICKNAME","bob");
    rtmfp.send("LIST_ITEMS",["1","2","3","4"]);
    

Demos

References

Rtmfp documentation
If you want to modify the flash applet...
Javascript libraries use