2 Replies Latest reply on Nov 23, 2009 7:52 AM by MApfelbeck

    Peer to Peer connection isn't working(code included)


      I'm trying to get a peer to peer connection up and running and I'm running into a problem. when I try to subscribe to a channel it doesn't seem to work.


      After I connect my NetConnection to stratus and get my NetConnection.Connect.Success NetStatus event I create a NetStream that publishes to a channel named "ping" and one that plays it. I get a NetStream.Publish.Start NetStatusEvent from the sending stream so I'm guessing that works but when I check the number of peerStreams attached to the sending stream it's 0 and when I try to send over the channel nothing happens.


      My net connection looks like this:

           _net.addEventListener (NetStatusEvent.NET_STATUS, NetStatus);



      and when the connection come up I create the NetStreams:
              public function NetStatus(result : NetStatusEvent)
                  _statusField.text = result.info.code;
                  if (result.info.code == "NetConnection.Connect.Success")
                      _statusField.text = result.info.code;
                      _sendStream = new NetStream(_net, NetStream.DIRECT_CONNECTIONS);
                      _sendStream.client = this;
                      _sendStream.addEventListener(NetStatusEvent.NET_STATUS, sendStreamHandler);


                      _recieveStream = new NetStream(_net,_net.nearID);
                      _recieveStream.client = this;
                      _recieveStream.addEventListener(NetStatusEvent.NET_STATUS, recieveStreamHandler);


                      _pingEnabled = true;


      But when I send:

           _sendStream.send("onPingRecieve", "ping?");


      Nothing happens.


      Can anyone tell me what I'm doing wrong? I attached a running sample with just the relivent code.