Class ModuleBase

  • Direct Known Subclasses:
    ModuleClientLogging, ModuleCore, ModuleMediaCaster

    public abstract class ModuleBase
    extends Object

    ModuleBase: Base class that all server side modules should extend. Provides basic utility functionality for handling function parameters and return data. Also provides a simplified API for logging.

    • Constructor Detail

      • ModuleBase

        public ModuleBase()
    • Method Detail

      • getParamCount

        protected static int getParamCount​(AMFDataList params)
        Get the total number of parameters passed to method.
        Parameters:
        params - parameters
        Returns:
        total number of parameters
      • getCallbackParamCount

        protected static int getCallbackParamCount​(AMFDataList params)
        Get the total number of parameters passed to callback.
        Parameters:
        params - parameters
        Returns:
        total number of parameters
      • getParamType

        protected static int getParamType​(AMFDataList params,
                                          int index)
        Get parameter type.
        Parameters:
        params - parameters
        index - parameter index
        Returns:
        parameter type (AMFData.DATA_TYPE_*)
      • getParam

        protected static AMFData getParam​(AMFDataList params,
                                          int index)
        Get parameter by index. Return as AMFData object.
        Parameters:
        params - parameters
        index - parameter index
        Returns:
        parameter value as AMFData object, null if out of bounds
      • getParamMixedArray

        protected static AMFDataMixedArray getParamMixedArray​(AMFDataList params,
                                                              int index)
        Get parameter by index, Return as AMFDataMixedArray.
        Parameters:
        params - parameters
        index - parameter index
        Returns:
        parameter value as AMFDataMixedArray object, null if out of bounds
      • getParamObj

        protected static AMFDataObj getParamObj​(AMFDataList params,
                                                int index)
        Get parameter by index, Return as Object.
        Parameters:
        params - parameters
        index - parameter index
        Returns:
        parameter value as Object object, null if out of bounds
      • getParamString

        protected static String getParamString​(AMFDataList params,
                                               int index)
        Get parameter by index, Return as String.
        Parameters:
        params - parameters
        index - parameter index
        Returns:
        parameter value as String object, null if out of bounds
      • getParamString

        protected static String getParamString​(AMFDataList params,
                                               int index,
                                               String defaultVal)
        Get parameter by index, Return as String.
        Parameters:
        params - parameters
        index - parameter index
        defaultVal - default value
        Returns:
        parameter value as String object, defaultVal if out of bounds
      • getParamDate

        protected static java.util.Date getParamDate​(AMFDataList params,
                                                     int index)
        Get parameter by index, Return as Date.
        Parameters:
        params - parameters
        index - parameter index
        Returns:
        parameter value as Date object, null if out of bounds
      • getParamInt

        protected static int getParamInt​(AMFDataList params,
                                         int index)
        Get parameter by index, Return as int.
        Parameters:
        params - parameters
        index - parameter index
        Returns:
        parameter value as int, 0 if out of bounds
      • getParamInt

        protected static int getParamInt​(AMFDataList params,
                                         int index,
                                         int defaultVal)
        Get parameter by index, Return as int.
        Parameters:
        params - parameters
        index - parameter index
        defaultVal - default value
        Returns:
        parameter value as int, defaultVal if out of bounds
      • getParamDouble

        protected static double getParamDouble​(AMFDataList params,
                                               int index)
        Get parameter by index, Return as double.
        Parameters:
        params - parameters
        index - parameter index
        Returns:
        parameter value as double, 0 if out of bounds
      • getParamDouble

        protected static double getParamDouble​(AMFDataList params,
                                               int index,
                                               double defaultVal)
        Get parameter by index, Return as double.
        Parameters:
        params - parameters
        index - parameter index
        defaultVal - default value
        Returns:
        parameter value as double, 0 if out of bounds
      • getParamLong

        protected static long getParamLong​(AMFDataList params,
                                           int index)
        Get parameter by index, Return as long.
        Parameters:
        params - parameters
        index - parameter index
        Returns:
        parameter value as long, 0 if out of bounds
      • getParamLong

        protected static long getParamLong​(AMFDataList params,
                                           int index,
                                           long defaultVal)
        Get parameter by index, Return as long.
        Parameters:
        params - parameters
        index - parameter index
        defaultVal - default value
        Returns:
        parameter value as long, defaultVal if out of bounds
      • getParamBoolean

        protected static boolean getParamBoolean​(AMFDataList params,
                                                 int index)
        Get parameter by index, Return as boolean.
        Parameters:
        params - parameters
        index - parameter index
        Returns:
        parameter value as boolean, false if out of bounds
      • getParamBoolean

        protected static boolean getParamBoolean​(AMFDataList params,
                                                 int index,
                                                 boolean defaultVal)
        Get parameter by index, Return as boolean.
        Parameters:
        params - parameters
        index - parameter index
        defaultVal - default value
        Returns:
        parameter value as boolean, defaultVal if out of bounds
      • getAppInstance

        protected static IApplicationInstance getAppInstance​(IClient client)
        Get applicationInstace of a client.
        Parameters:
        client - client
        Returns:
        applicationInstance
      • getApplication

        protected static IApplication getApplication​(IClient client)
        Get application of a client.
        Parameters:
        client - client
        Returns:
        application
      • isSendResult

        protected static boolean isSendResult​(AMFDataList params)
        Is this method call expecting sendResult to be called. If on the client side the call to NetConnection.call("handlerName", resultObj, param1...); had a value for resultObj (non-null), then the method is expecting some type of result or return data. Calling a variant of sendResult will provide this callback.
        Parameters:
        params - parameters
        Returns:
        true if client side call is expecting call to sendResult
      • getVHost

        protected static IVHost getVHost​(IClient client)
        Get vHost of a client.
        Parameters:
        client - client
        Returns:
        vHost
      • sendResult

        protected static boolean sendResult​(IClient client,
                                            AMFDataList params,
                                            String value)
        Send a result to client method call as a single String value.
        Parameters:
        client - client
        params - parameters
        value - return value
        Returns:
        true if client side call is expecting call to sendResult
      • sendResult

        protected static boolean sendResult​(IClient client,
                                            AMFDataList params,
                                            boolean value)
        Send a result to client method call as a single boolean value.
        Parameters:
        client - client
        params - parameters
        value - return value
        Returns:
        true if client side call is expecting call to sendResult
      • sendResult

        protected static boolean sendResult​(IClient client,
                                            AMFDataList params,
                                            int value)
        Send a result to client method call as a single int value.
        Parameters:
        client - client
        params - parameters
        value - return value
        Returns:
        true if client side call is expecting call to sendResult
      • sendResult

        protected static boolean sendResult​(IClient client,
                                            AMFDataList params,
                                            double value)
        Send a result to client method call as a single double value.
        Parameters:
        client - client
        params - parameters
        value - return value
        Returns:
        true if client side call is expecting call to sendResult
      • sendResult

        protected static boolean sendResult​(IClient client,
                                            AMFDataList params,
                                            AMFData data)
        Send a result to client method call as a AMFData object. This can be a single AMFData value like new AMFDataItem((double)1.234) or a complex type like AMFDataMixedArray, AMFDataArray or AMFDataObj.
        Parameters:
        client - client
        params - parameters
        data - return value
        Returns:
        true if client side call is expecting call to sendResult
      • getLogger

        protected static WMSLogger getLogger()
        Get the logging interface.
        Returns:
        logging interface
      • getLogger

        protected static WMSLogger getLogger​(Class classObj)
        Get the logging interface.
        Parameters:
        classObj - class object
        Returns:
        logging interface
      • getLogger

        protected static WMSLogger getLogger​(Class classObj,
                                             IApplicationInstance appInstance)
        Get the logging interface.
        Parameters:
        classObj - class object
        appInstance - application instance
        Returns:
        logging interface
      • getStream

        protected static IMediaStream getStream​(IClient client,
                                                com.wowza.wms.request.RequestFunction function)
        For methods called from the client side object NetStream (publish, play, deleteStream) get the IMediaStream object associated with the call.
        Parameters:
        client - client
        function - functions
        Returns:
        media stream
      • invokePrevious

        protected static void invokePrevious​(Object instance,
                                             IClient client,
                                             com.wowza.wms.request.RequestFunction function,
                                             AMFDataList params)
        Wowza Pro will determine command priority based on the order of the modules in the module list. Wowza Pro by default will only invoke the last module that defines a given command. This method enables you to call the method by the same name in the previous module that defines that command. For example if you have three modules defined in the module list; ModuleCore, ModuleSecureURLParams and ModuleMyModule and all three modules implement the "play" command. When "play" is invoked it will invoke the "play" command in ModuleMyModule. If in ModuleMyModule you would like to call the "play" command in ModuleSecureURLParams, you can call: invokePrevious(this, client, function, params); and it will invoke the "play" command defined in ModuleSecureURLParams.
        Parameters:
        instance - instance of the current module
        client - client object passed into command
        function - function passed into command
        params - parameters passed into command
      • invokePrevious

        protected void invokePrevious​(IClient client,
                                      com.wowza.wms.request.RequestFunction function,
                                      AMFDataList params)
        Wowza Pro will determine command priority based on the order of the modules in the module list. Wowza Pro by default will only invoke the last module that defines a given command. This method enables you to call the method by the same name in the previous module that defines that command. For example if you have three modules defined in the module list; ModuleCore, ModuleSecureURLParams and ModuleMyModule and all three modules implement the "play" command. When "play" is invoked it will invoke the "play" command in ModuleMyModule. If in ModuleMyModule you would like to call the "play" command in ModuleSecureURLParams, you can call: this.invokePrevious(client, function, params); and it will invoke the "play" command defined in ModuleSecureURLParams.
        Parameters:
        client - client object passed into command
        function - function passed into command
        params - parameters passed into command
      • sendClientOnStatusError

        protected static void sendClientOnStatusError​(IClient client,
                                                      String code,
                                                      String description)
        Send an error message to the client-side client.onStatus handler
        Parameters:
        client - destination client
        code - code
        description - description
      • sendStreamOnStatusError

        protected static void sendStreamOnStatusError​(IMediaStream stream,
                                                      String code,
                                                      String description)
        Send an error to the client-side NetStream.onStatus handler
        Parameters:
        stream - destination stream
        code - code
        description - description