flex - What hinders NetStream.onPeerConnect from being triggered? -
i'm using adobe stratus (now renamed cirrus) build p2p application. inside application, used netstream.onpeerconnect callback function , expected triggered every time when peer connected. however, failed friend while strangely friend b managed have function called without problem.
i wondering cause issue?
here how code pieces like.
first of all, create netconnection.
netconnection = new netconnection(); netconnection.addeventlistener(netstatusevent.net_status, netconnectionhandler); netconnection.connect(server_address+developer_key);
secondly, create netstream upon netconnection 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 build connection between 2 peers
receivedstream = new netstream(netconnection, farid); receivedstream.client = this; receivedstream.addeventlistener(netstatusevent.net_status, incomingstreamhandler); receivedstream.play("file");
please enlighten me. thanks!
it turns out friend behind symmetric nat. i'm thinking setup turn server build successful connection.
Comments
Post a Comment