Hi,
When a subsribing peer tries to connect to the publishing peer to play the stream, the callback method "onPeerConnect" is executed automatically. But what if any peer (i.e. publishing or subscribing) gets disconnected due to any reason? is there any callback function that is triggered automatically in that case also?
Thanks in advance.
I had your same problem & this is how I solved it:
Once the application is activated, each client (SWF) makes a call to the database every 10 seconds (you can decide your own timeframe) & updates their record with a fresh timeStamp. If the client stops making calls to the database, the timeStamp gets old & is cleared out by another job that runs every few minutes (you can decide your own timeframe) if its timeStamp is older than 2 minutes.
This has been very effective for me & my team to keep an accurate listing of active user IDs.
Hope this helps,
RGB
I've also been working on disconect detection and reconnection (where possible).
I hope there's a way to detect a disconnect using only stratus.
Here's what I have so far and I hope someone else can shed more light on this.
It looks like a couple events get fired when a disconnect happens.
NetStream.Connect.Closed
if you have this set you will see it ...
netConnection.addEventListener(NetStatusEvent.NET_STATUS,blahlbah
and
NetStream.Play.UnpublishNotify
seems to fire when other peer's outNetStream closes
I hope someone from Adobe can give us more info.
A user disconnect event is about as basic as it gets for this kind of stuff.
Hi,
you need to use the netstatus listener on the netconnection.
"NetStream.Connect.Closed" is fired on disconnection.
You can than check the farID with - info.stream.farID.
You can also check if the netstream is the correct one by comparing the clients - if(event.info.stream.client==NetStrm.client){}
netconnection.addEventListener(NetStatusEvent.NET_STATUS,OnStreamStatu s,false,0,true)
NetStrm = new NetStream(netconnection,peerid)
public function OnStreamStatus(event:NetStatusEvent):void
{
if(event.info.code=="NetStream.Connect.Closed")
{
if(event.info.stream.client==NetStrm.client)
{
CurrentPeerId = data.info.stream.farID
dispatchEvent(OnDisconnected)
}
}
}
That is how I'm doing it too.
However it seems to be unreliable since sometimes after that event fires the two peers are still connected and can still send messages to each other.
For me it means that the peer "might" have disconnected so I need to ping it.
Does anyone know why that would fire that event when the peers are still connected?
Here's is more detailed disconnection info I've found to work anecdotally.
Could someone from Adobe please confirm that this is correct.
I think this kind of disconnect/reconnect info should be in the NetStream/NetConnetion docs/tuts.
Each peer has an inStream and an outStream, I can detect the following 4 disconnection events:
a) My Peer's inStream has disconnected : onInNetStreamStatus NetStream.Play.Stop
b) My Peer's outStream has disconnected : onOutNetStreamStatus NetStream.Play.Stop
c) Remote Peer's inStream has disconnected : onNetConnectionStatus NetStream.Connect.Closed //if(event.info.stream != inNetStream
d) Remote Peer's outStream has disconnected : onNetConnectionStatus NetStream.Connect.Closed //if(event.info.stream == inNetStream
North America
Europe, Middle East and Africa
Asia Pacific