I'm using Adobe Stratus (now renamed to Cirrus) to build a p2p application. Inside the application, I used NetStream.onPeerConnect callback function and expected it to be triggered every time when a peer is connected. However, it always failed with my friend A while strangely friend B managed to have the function called without any problem.
I was wondering what could be the cause to this issue?
Here are how the code pieces look like.
First of all, create a NetConnection.
netConnection = new NetConnection();
netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnectionHandler);
netConnection.connect(SERVER_ADDRESS+DEVELOPER_KEY);
Secondly, create NetStream upon NetConnection successfully connected.
private function netConnectionHandler(event:NetStatusEvent):void{
    switch (event.info.code){
        case "NetConnection.Connect.Success":
            sendStream = new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS);
            sendStream.addEventListener(NetStatusEvent.NET_STATUS, netStreamHandler);
            var sendObj:Object = new Object();
            sendObj.onPeerConnect = function(subscriber:NetStream) : Boolean {
                trace("[onPeerConnect] far id: " + subscriber.farID);
                return true;
            } 
            sendStream.client = sendObj;
            sendStream.publish("file");
            ......
Thirdly, here's how I build the connection between two peers
    receivedStream = new NetStream(netConnection, farId);
    receive开发者_Go百科dStream.client = this;
    receivedStream.addEventListener(NetStatusEvent.NET_STATUS, incomingStreamHandler);
    receivedStream.play("file");
Please help enlighten me. Thanks!
It turns out my friend A is behind a symmetric NAT. I'm thinking to setup a TURN server for us to build a successful connection.
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
 加载中,请稍侯......
      
精彩评论