client and send() method
Posted: 20 Dec 2012, 10:57
Trying to used netStream.send method for indicate if user on or off microphone and activity of it.
But for some reason it doens't work.
sender code send is bound to button and microphone is perfectly attaching and detaching, but for some reason on reciever i don't see any action bounded to netStream.client, even traces and no errors.
Receiver
i'm using AVCastManager from RedBox
But for some reason it doens't work.
sender code send is bound to button and microphone is perfectly attaching and detaching, but for some reason on reciever i don't see any action bounded to netStream.client, even traces and no errors.
Code: Select all
private function mic_btn_down(evt:MouseEvent)
{
if (playerStreams[myPlayerID - 1] != null)
{
(playerStreams[myPlayerID - 1] as NetStream).attachAudio(micSnd);
(playerStreams[myPlayerID - 1] as NetStream).send("mic", { state: "on", pID: myPlayerID} );
micSnd.addEventListener(ActivityEvent.ACTIVITY, micAct);
}
}
private function mic_btn_up(evt:MouseEvent)
{
if (playerStreams[myPlayerID - 1] != null)
{
(playerStreams[myPlayerID - 1] as NetStream).attachAudio(null);
(playerStreams[myPlayerID - 1] as NetStream).send("mic", { state: "off", pID: myPlayerID} );
micSnd.removeEventListener(ActivityEvent.ACTIVITY, micAct);
}
}
private function micAct(evt:ActivityEvent)
{
(playerStreams[myPlayerID - 1] as NetStream).send("talk", { pID: myPlayerID, actLev:micSnd.activityLevel } );
}Code: Select all
public function initListener(id:int)
{
var obj:Object = new Object();
obj.mic = onMicSC;
obj.talk = onTalk;
streams[id].client = obj;
}
private function onTalk(obj:Object)
{
//obj.pID
//obj.actLev
trace("pID: " + obj.pID + " _ actLevel: " + obj.actLev);
}
//On microphone state change
private function onMicSC(obj:Object)
{
trace("!@microphon state oN_oFF @!");
if (obj.state == "on")
{
trace("micOn: " + obj.pID);
micOn(obj.pID-1);
} else {
trace("micOff: " + obj.pID);
micOff(obj.pID-1);
}
}