Reputation: 1275
I have code that makes a call to my main.acs
and then broadcasts a message out to all the users. When I broadcast my message out to all users, the bcStopStreaming function never gets called.
Server Side code:
application.onConnect = function(client) {
application.acceptConnection(client);
client.stopStreaming = function() {
trace("#stopStreaming# called");
application.broadcastMsg("bcStopStreaming");
}
client.startStreaming = function() {
trace("#startStreaming# called");
application.broadcastMsg("bcStreaming");
}
}
Connect Button:
public function btnConnectHandler(event:MouseEvent):void
{
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect("rtmp://"+hostName+"/test");
nc.client = new Object();
nc.client.bcStreaming = function(){
trace("Started Streaming");
};
nc.client.bcStopStreaming = function(){
trace("Stopped Streaming");
};
}
Disconnect Button:
public function btnDisconnectHandler(event:MouseEvent):void {
nc.call("stopStreaming", null);
nc.close();
}
Error I get:
Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback bcStreaming. error=ReferenceError: Error #1069: Property bcStreaming not found on test and there is no default value.
at test/btnConnectHandler()
Upvotes: 0
Views: 936
Reputation: 6402
Your client is not set up correctly.
And please stop using inline functions.
public function btnConnectHandler(event:MouseEvent):void{
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect("rtmp://"+hostName+"/test");
var myClient = new Object()
myClient.bcStreaming = this.bcStreaming;
myClient.bcStopStreaming = this.bcStopStreaming;
nc.client = myClient;
}
public function bcStreaming(){
trace("Started Streaming");
}
public function bcStopStreaming(){
trace("Stopped Streaming");
}
Upvotes: 1