Search code examples
javaactionscript-3flashvideo-streamingwowza

How to stop streaming in the publish method of Wowza server


I need to stop publishing the stream in the publish() method and send the client a message such as "This name is incorrect, choose another."

I've looked at sendClientOnErrorStatus() but haven't found any examples showing how to handle it on the client side.

Also, can anyone explain what the sendResult(..) method does?


Solution

  • sendClientOnErrorStatus() and sendResult() only work in a Flash context.

    sendClientOnErrorStatus()

    On the Wowza server you can override the publish and releaseStream (for streams being published) methods and do something like:

    sendClientOnStatusError(client, "NetStream.Publish.Denied", "Stream name is invalid: " + streamName);

    On a Flash client using ActionScript you would add a NetStatusEvent listener:

    nc = new NetConnection();
    nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    
    private function netStatusHandler(event:NetStatusEvent):void {
           switch (event.info.code) {
                // do something with the event.info
           }
    }
    

    sendResult()

    This is used to send the result for a NetConnection.call which calls a custom method on the Wowza server.

    Example:

    Wowza server:

    public void someMethod(IClient client, RequestFunction function,
                AMFDataList params) {
    {
            sendResult(client, params, "response");
    }
    

    Client:

    nc = new NetConnection();
    nc.call("someMethod",new Responder(function(data:String):void {
              trace(data);
           })
    );
    

    Source: AS3 Reference