Event Script Reference

Event Script Reference

The following events are available.

Event: playlist_advanced

Description

Called every time a track is selected from a playlist for the autoDJ.

Note that is imperative that your script work very quickly. During the execution of your script, the autoDJ is forced to wait to receive the information for the next track. If your script takes too long, the current song may end before the autoDJ knows which track to play next, and as a result, there may be silence on the stream and/or the server may believe that the source has died due to inactivity. You may wish to design your script to fork, exit, and and continue operation in the background if processing will take more than a few hundred milliseconds.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • pathname (string)
    the pathname of the track to be played

  • artist (string)
    the artist of the track to be played

  • album (string)
    the album of the track to be played

  • title (string)
    the title of the track to be played

  • length (int)
    the length of the track to be played, in seconds

  • royaltycode (string)
    the royalty reporting code of the track to be played

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('playlist_advanced',array(&$this,'handle_playlist_advanced'));
    }

    /**
     * Handles the playlist_advanced event
     *
     * @param string $username the username of the account
     * @param string $pathname the pathname of the track to be played
     * @param string $artist the artist of the track to be played
     * @param string $album the album of the track to be played
     * @param string $title the title of the track to be played
     * @param int $length the length of the track to be played, in seconds
     * @param string $royaltycode the royalty reporting code of the track to be played
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_playlist_advanced($username,$pathname,$artist,$album,$title,$length,$royaltycode) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-create-reseller

Description

Called just before a reseller account is created.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • password (string)
    the password for the account

  • email (string)
    the email address for the account

  • maxclients (int)
    the listener limit for the account

  • maxbitrate (int)
    the maximum bit rate for the account

  • transferlimit (int)
    the data transfer limit for the account

  • diskquota (int)
    the disk quota for the account

  • usesource (int)
    1 if the reseller can create autoDJ-enabled accounts, otherwise 0

  • mountlimit (int)
    the mount point limit for the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the account from being created.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-create-reseller',array(&$this,'handle_precreatereseller'));
    }

    /**
     * Handles the pre-create-reseller event
     *
     * @param string $username the username of the account
     * @param string $password the password for the account
     * @param string $email the email address for the account
     * @param int $maxclients the listener limit for the account
     * @param int $maxbitrate the maximum bit rate for the account
     * @param int $transferlimit the data transfer limit for the account
     * @param int $diskquota the disk quota for the account
     * @param int $usesource 1 if the reseller can create autoDJ-enabled accounts, otherwise 0
     * @param int $mountlimit the mount point limit for the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_precreatereseller($username,$password,$email,$maxclients,$maxbitrate,$transferlimit,$diskquota,$usesource,$mountlimit) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: pre-create-account

Description

Called just before a streaming account is created.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • password (string)
    the password for the account

  • email (string)
    the email address for the account

  • ipaddress (string)
    the IP address for the account

  • port (int)
    the port number for the account

  • maxclients (int)
    the listener limit for the account

  • maxbitrate (int)
    the maximum bit rate for the account

  • transferlimit (int)
    the data transfer limit for the account

  • diskquota (int)
    the disk quota for the account

  • usesource (int)
    1 if the autoDJ is enabled, otherwise 0

  • mountlimit (int)
    the mount point limit for the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the account from being created.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-create-account',array(&$this,'handle_precreateaccount'));
    }

    /**
     * Handles the pre-create-account event
     *
     * @param string $username the username of the account
     * @param string $password the password for the account
     * @param string $email the email address for the account
     * @param string $ipaddress the IP address for the account
     * @param int $port the port number for the account
     * @param int $maxclients the listener limit for the account
     * @param int $maxbitrate the maximum bit rate for the account
     * @param int $transferlimit the data transfer limit for the account
     * @param int $diskquota the disk quota for the account
     * @param int $usesource 1 if the autoDJ is enabled, otherwise 0
     * @param int $mountlimit the mount point limit for the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_precreateaccount($username,$password,$email,$ipaddress,$port,$maxclients,$maxbitrate,$transferlimit,$diskquota,$usesource,$mountlimit) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-create-reseller

Description

Called just after a reseller account is created.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • password (string)
    the password for the account

  • email (string)
    the email address for the account

  • maxclients (int)
    the listener limit for the account

  • maxbitrate (int)
    the maximum bit rate for the account

  • transferlimit (int)
    the data transfer limit for the account

  • diskquota (int)
    the disk quota for the account

  • usesource (int)
    1 if the reseller can create autoDJ-enabled accounts, otherwise 0

  • mountlimit (int)
    the mount point limit for the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-create-reseller',array(&$this,'handle_postcreatereseller'));
    }

    /**
     * Handles the post-create-reseller event
     *
     * @param string $username the username of the account
     * @param string $password the password for the account
     * @param string $email the email address for the account
     * @param int $maxclients the listener limit for the account
     * @param int $maxbitrate the maximum bit rate for the account
     * @param int $transferlimit the data transfer limit for the account
     * @param int $diskquota the disk quota for the account
     * @param int $usesource 1 if the reseller can create autoDJ-enabled accounts, otherwise 0
     * @param int $mountlimit the mount point limit for the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postcreatereseller($username,$password,$email,$maxclients,$maxbitrate,$transferlimit,$diskquota,$usesource,$mountlimit) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: post-create-account

Description

Called just after a streaming account is created.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • password (string)
    the password for the account

  • email (string)
    the email address for the account

  • ipaddress (string)
    the IP address for the account

  • port (int)
    the port number for the account

  • maxclients (int)
    the listener limit for the account

  • maxbitrate (int)
    the maximum bit rate for the account

  • transferlimit (int)
    the data transfer limit for the account

  • diskquota (int)
    the disk quota for the account

  • usesource (int)
    1 if the autoDJ is enabled, otherwise 0

  • mountlimit (int)
    the mount point limit for the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-create-account',array(&$this,'handle_postcreateaccount'));
    }

    /**
     * Handles the post-create-account event
     *
     * @param string $username the username of the account
     * @param string $password the password for the account
     * @param string $email the email address for the account
     * @param string $ipaddress the IP address for the account
     * @param int $port the port number for the account
     * @param int $maxclients the listener limit for the account
     * @param int $maxbitrate the maximum bit rate for the account
     * @param int $transferlimit the data transfer limit for the account
     * @param int $diskquota the disk quota for the account
     * @param int $usesource 1 if the autoDJ is enabled, otherwise 0
     * @param int $mountlimit the mount point limit for the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postcreateaccount($username,$password,$email,$ipaddress,$port,$maxclients,$maxbitrate,$transferlimit,$diskquota,$usesource,$mountlimit) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-terminate-account

Description

Called just before a streaming account is terminated.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the account from being terminated.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-terminate-account',array(&$this,'handle_preterminateaccount'));
    }

    /**
     * Handles the pre-terminate-account event
     *
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_preterminateaccount($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: pre-terminate-reseller

Description

Called just before a reseller account is terminated.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the account from being terminated.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-terminate-reseller',array(&$this,'handle_preterminatereseller'));
    }

    /**
     * Handles the pre-terminate-reseller event
     *
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_preterminatereseller($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-terminate-account

Description

Called just after a streaming account is terminated

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-terminate-account',array(&$this,'handle_postterminateaccount'));
    }

    /**
     * Handles the post-terminate-account event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postterminateaccount($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: post-terminate-reseller

Description

Called just after a reseller account is terminated

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-terminate-reseller',array(&$this,'handle_postterminatereseller'));
    }

    /**
     * Handles the post-terminate-reseller event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postterminatereseller($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-reparent-account

Description

Called just before a streaming account is moved to a new reseller

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • newreseller (string)
    the username of the new reseller account to own the streaming account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the streaming server from being reparented.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-reparent-account',array(&$this,'handle_prereparentaccount'));
    }

    /**
     * Handles the pre-reparent-account event
     *
     * @param string $username the username of the account
     * @param string $newreseller the username of the new reseller account to own the streaming account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_prereparentaccount($username,$newreseller) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-reparent-account

Description

Called just after a streaming account is moved to a new reseller

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • newreseller (string)
    the username of the new reseller account to own the streaming account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-reparent-account',array(&$this,'handle_postreparentaccount'));
    }

    /**
     * Handles the post-reparent-account event
     *
     * @param string $username the username of the account
     * @param string $newreseller the username of the new reseller account to own the streaming account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postreparentaccount($username,$newreseller) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-account-status

Description

Called just before a streaming account's status (enabled/disabled) is changed

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • status (string)
    the new status for the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the account's status from changing.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-account-status',array(&$this,'handle_preaccountstatus'));
    }

    /**
     * Handles the pre-account-status event
     *
     * @param string $username the username of the account
     * @param string $status the new status for the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_preaccountstatus($username,$status) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-account-status

Description

Called just after a streaming account's status (enabled/disabled) is changed

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • status (string)
    the new status for the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-account-status',array(&$this,'handle_postaccountstatus'));
    }

    /**
     * Handles the post-account-status event
     *
     * @param string $username the username of the account
     * @param string $status the new status for the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postaccountstatus($username,$status) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-start-server

Description

Called just before a streaming server is started.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the streaming server from starting.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-start-server',array(&$this,'handle_prestartserver'));
    }

    /**
     * Handles the pre-start-server event
     *
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_prestartserver($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-start-server

Description

Called just after a streaming server is started.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-start-server',array(&$this,'handle_poststartserver'));
    }

    /**
     * Handles the post-start-server event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_poststartserver($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-start-source

Description

Called just before an autoDJ is started.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the autoDJ from starting.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-start-source',array(&$this,'handle_prestartsource'));
    }

    /**
     * Handles the pre-start-source event
     *
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_prestartsource($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: pre-start-app

Description

Called just before a supplemental application is started.

Parameters

The following parameters are passed, in the order shown, to this script:

  • type (string)
    the application type

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the application from starting.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-start-app',array(&$this,'handle_prestartapp'));
    }

    /**
     * Handles the pre-start-app event
     *
     * @param string $type the application type
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_prestartapp($type,$username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-start-source

Description

Called just after an autoDJ is started.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-start-source',array(&$this,'handle_poststartsource'));
    }

    /**
     * Handles the post-start-source event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_poststartsource($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: post-start-app

Description

Called just after a supplemental application is started.

Parameters

The following parameters are passed, in the order shown, to this script:

  • type (string)
    the application type

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-start-app',array(&$this,'handle_poststartapp'));
    }

    /**
     * Handles the post-start-app event
     *
     * @param string $type the application type
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_poststartapp($type,$username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-reload

Description

Called just before a streaming server is reloaded.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the streaming server from reloading.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-reload',array(&$this,'handle_prereload'));
    }

    /**
     * Handles the pre-reload event
     *
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_prereload($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-reload

Description

Called just after a streaming server is reloaded.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-reload',array(&$this,'handle_postreload'));
    }

    /**
     * Handles the post-reload event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postreload($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-stop-source

Description

Called just before an autoDJ is stopped.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the autoDJ from stopping.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-stop-source',array(&$this,'handle_prestopsource'));
    }

    /**
     * Handles the pre-stop-source event
     *
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_prestopsource($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: pre-stop-app

Description

Called just before a supplemental application is stopped.

Parameters

The following parameters are passed, in the order shown, to this script:

  • type (string)
    the application type

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the application from stopping.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-stop-app',array(&$this,'handle_prestopapp'));
    }

    /**
     * Handles the pre-stop-app event
     *
     * @param string $type the application type
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_prestopapp($type,$username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-stop-source

Description

Called just after an autoDJ is stopped.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-stop-source',array(&$this,'handle_poststopsource'));
    }

    /**
     * Handles the post-stop-source event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_poststopsource($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: post-stop-app

Description

Called just after a supplemental application is stopped.

Parameters

The following parameters are passed, in the order shown, to this script:

  • app (string)
    the application type

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-stop-app',array(&$this,'handle_poststopapp'));
    }

    /**
     * Handles the post-stop-app event
     *
     * @param string $app the application type
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_poststopapp($app,$username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-stop-server

Description

Called just before a streaming server is stopped.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the streaming server from stopping.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-stop-server',array(&$this,'handle_prestopserver'));
    }

    /**
     * Handles the pre-stop-server event
     *
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_prestopserver($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-stop-server

Description

Called just after a streaming server is stopped.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-stop-server',array(&$this,'handle_poststopserver'));
    }

    /**
     * Handles the post-stop-server event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_poststopserver($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-reindex

Description

Called just before a media library is reindexed (updated).

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the media library from updating.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-reindex',array(&$this,'handle_prereindex'));
    }

    /**
     * Handles the pre-reindex event
     *
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_prereindex($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-reindex

Description

Called just after a media library is reindexed (updated).

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-reindex',array(&$this,'handle_postreindex'));
    }

    /**
     * Handles the post-reindex event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postreindex($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-process-logs

Description

Called just before an account's logs are processed.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the processing of the account's logs.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-process-logs',array(&$this,'handle_preprocesslogs'));
    }

    /**
     * Handles the pre-process-logs event
     *
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_preprocesslogs($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-process-logs

Description

Called just after an account's logs have been processed.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-process-logs',array(&$this,'handle_postprocesslogs'));
    }

    /**
     * Handles the post-process-logs event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postprocesslogs($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-rotate-logs

Description

Called just before an account's logs are rotated.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the rotation of the account's logs.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-rotate-logs',array(&$this,'handle_prerotatelogs'));
    }

    /**
     * Handles the pre-rotate-logs event
     *
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_prerotatelogs($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-rotate-logs

Description

Called just after an account's logs have been rotated.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-rotate-logs',array(&$this,'handle_postrotatelogs'));
    }

    /**
     * Handles the post-rotate-logs event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postrotatelogs($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: pre-update-reseller

Description

Called just before a reseller account is updated.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • password (string)
    the password for the account

  • email (string)
    the email address for the account

  • maxclients (int)
    the listener limit for the account

  • maxbitrate (int)
    the maximum bit rate for the account

  • transferlimit (int)
    the data transfer limit for the account

  • diskquota (int)
    the disk quota for the account

  • usesource (int)
    1 if the reseller can create autoDJ-enabled accounts, otherwise 0

  • mountlimit (int)
    the mount point limit for the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the update from being saved.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-update-reseller',array(&$this,'handle_preupdatereseller'));
    }

    /**
     * Handles the pre-update-reseller event
     *
     * @param string $username the username of the account
     * @param string $password the password for the account
     * @param string $email the email address for the account
     * @param int $maxclients the listener limit for the account
     * @param int $maxbitrate the maximum bit rate for the account
     * @param int $transferlimit the data transfer limit for the account
     * @param int $diskquota the disk quota for the account
     * @param int $usesource 1 if the reseller can create autoDJ-enabled accounts, otherwise 0
     * @param int $mountlimit the mount point limit for the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_preupdatereseller($username,$password,$email,$maxclients,$maxbitrate,$transferlimit,$diskquota,$usesource,$mountlimit) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: pre-update-account

Description

Called just before a streaming account is updated.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • password (string)
    the password for the account

  • email (string)
    the email address for the account

  • ipaddress (string)
    the IP address for the account

  • port (int)
    the port number for the account

  • maxclients (int)
    the listener limit for the account

  • maxbitrate (int)
    the maximum bit rate for the account

  • transferlimit (int)
    the data transfer limit for the account

  • diskquota (int)
    the disk quota for the account

  • usesource (int)
    1 if the autoDJ is enabled, otherwise 0

  • mountlimit (int)
    the mount point limit for the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the update from being saved.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-update-account',array(&$this,'handle_preupdateaccount'));
    }

    /**
     * Handles the pre-update-account event
     *
     * @param string $username the username of the account
     * @param string $password the password for the account
     * @param string $email the email address for the account
     * @param string $ipaddress the IP address for the account
     * @param int $port the port number for the account
     * @param int $maxclients the listener limit for the account
     * @param int $maxbitrate the maximum bit rate for the account
     * @param int $transferlimit the data transfer limit for the account
     * @param int $diskquota the disk quota for the account
     * @param int $usesource 1 if the autoDJ is enabled, otherwise 0
     * @param int $mountlimit the mount point limit for the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_preupdateaccount($username,$password,$email,$ipaddress,$port,$maxclients,$maxbitrate,$transferlimit,$diskquota,$usesource,$mountlimit) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-update-reseller

Description

Called just after a reseller account is updated.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • password (string)
    the password for the account

  • email (string)
    the email address for the account

  • maxclients (int)
    the listener limit for the account

  • maxbitrate (int)
    the maximum bit rate for the account

  • transferlimit (int)
    the data transfer limit for the account

  • diskquota (int)
    the disk quota for the account

  • usesource (int)
    1 if the reseller can create autoDJ-enabled accounts, otherwise 0

  • mountlimit (int)
    the mount point limit for the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-update-reseller',array(&$this,'handle_postupdatereseller'));
    }

    /**
     * Handles the post-update-reseller event
     *
     * @param string $username the username of the account
     * @param string $password the password for the account
     * @param string $email the email address for the account
     * @param int $maxclients the listener limit for the account
     * @param int $maxbitrate the maximum bit rate for the account
     * @param int $transferlimit the data transfer limit for the account
     * @param int $diskquota the disk quota for the account
     * @param int $usesource 1 if the reseller can create autoDJ-enabled accounts, otherwise 0
     * @param int $mountlimit the mount point limit for the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postupdatereseller($username,$password,$email,$maxclients,$maxbitrate,$transferlimit,$diskquota,$usesource,$mountlimit) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: post-update-account

Description

Called just after a streaming account is updated.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

  • password (string)
    the password for the account

  • email (string)
    the email address for the account

  • ipaddress (string)
    the IP address for the account

  • port (int)
    the port number for the account

  • maxclients (int)
    the listener limit for the account

  • maxbitrate (int)
    the maximum bit rate for the account

  • transferlimit (int)
    the data transfer limit for the account

  • diskquota (int)
    the disk quota for the account

  • usesource (int)
    1 if the autoDJ is enabled, otherwise 0

  • mountlimit (int)
    the mount point limit for the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-update-account',array(&$this,'handle_postupdateaccount'));
    }

    /**
     * Handles the post-update-account event
     *
     * @param string $username the username of the account
     * @param string $password the password for the account
     * @param string $email the email address for the account
     * @param string $ipaddress the IP address for the account
     * @param int $port the port number for the account
     * @param int $maxclients the listener limit for the account
     * @param int $maxbitrate the maximum bit rate for the account
     * @param int $transferlimit the data transfer limit for the account
     * @param int $diskquota the disk quota for the account
     * @param int $usesource 1 if the autoDJ is enabled, otherwise 0
     * @param int $mountlimit the mount point limit for the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postupdateaccount($username,$password,$email,$ipaddress,$port,$maxclients,$maxbitrate,$transferlimit,$diskquota,$usesource,$mountlimit) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: send-email

Description

Called when Centova Cast needs to send an email message (usually for notifications).

Parameters

The following parameters are passed, in the order shown, to this script:

  • name (string)
    the name of the email template to send

  • recipients (array)
    a list of recipient email addresses for the message

  • subject (string)
    the subject for the message

  • variables (array)
    a list of variables available to be populated into the message text

  • text (string)
    the text/plain version of the message body

  • html (string)
    the text/html version of the message body

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and prevents the email from being sent by Centova Cast (useful if you use an external notification system).

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting triggers an error and prevents the email from being sent by Centova Cast.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('send-email',array(&$this,'handle_sendemail'));
    }

    /**
     * Handles the send-email event
     *
     * @param string $name the name of the email template to send
     * @param array $recipients a list of recipient email addresses for the message
     * @param string $subject the subject for the message
     * @param array $variables a list of variables available to be populated into the message text
     * @param string $text the text/plain version of the message body
     * @param string $html the text/html version of the message body
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_sendemail($name,$recipients,$subject,$variables,$text,$html) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: pre-rename-account

Description

Called just before a streaming account is renamed.

Parameters

The following parameters are passed, in the order shown, to this script:

  • old_username (string)
    the original (current) username of the account

  • new_username (string)
    the new username to be assigned to the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the account from being renamed.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-rename-account',array(&$this,'handle_prerenameaccount'));
    }

    /**
     * Handles the pre-rename-account event
     *
     * @param string $old_username the original (current) username of the account
     * @param string $new_username the new username to be assigned to the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_prerenameaccount($old_username,$new_username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: pre-rename-reseller

Description

Called just before a reseller account is renamed.

Parameters

The following parameters are passed, in the order shown, to this script:

  • old_username (string)
    the original (current) username of the account

  • new_username (string)
    the new username to be assigned to the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the account from being renamed.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('pre-rename-reseller',array(&$this,'handle_prerenamereseller'));
    }

    /**
     * Handles the pre-rename-reseller event
     *
     * @param string $old_username the original (current) username of the account
     * @param string $new_username the new username to be assigned to the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_prerenamereseller($old_username,$new_username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Event: post-rename-account

Description

Called just after a streaming account is renamed

Parameters

The following parameters are passed, in the order shown, to this script:

  • old_username (string)
    the original (old) username of the account

  • new_username (string)
    the new (current) username for the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-rename-account',array(&$this,'handle_postrenameaccount'));
    }

    /**
     * Handles the post-rename-account event
     *
     * @param string $old_username the original (old) username of the account
     * @param string $new_username the new (current) username for the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postrenameaccount($old_username,$new_username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: post-rename-reseller

Description

Called just after a reseller account is renamed

Parameters

The following parameters are passed, in the order shown, to this script:

  • old_username (string)
    the original (old) username of the account

  • new_username (string)
    the new (current) username for the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('post-rename-reseller',array(&$this,'handle_postrenamereseller'));
    }

    /**
     * Handles the post-rename-reseller event
     *
     * @param string $old_username the original (old) username of the account
     * @param string $new_username the new (current) username for the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_postrenamereseller($old_username,$new_username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: server-outage-restarted

Description

Called when a streaming server is restarted due to an outage

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('server-outage-restarted',array(&$this,'handle_serveroutagerestarted'));
    }

    /**
     * Handles the server-outage-restarted event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_serveroutagerestarted($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: server-outage-restart-failed

Description

Called when a streaming server cannot be restarted after an outage

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('server-outage-restart-failed',array(&$this,'handle_serveroutagerestartfailed'));
    }

    /**
     * Handles the server-outage-restart-failed event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_serveroutagerestartfailed($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: source-outage-restarted

Description

Called when an autoDJ is restarted due to an outage

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('source-outage-restarted',array(&$this,'handle_sourceoutagerestarted'));
    }

    /**
     * Handles the source-outage-restarted event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_sourceoutagerestarted($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: source-outage-restart-failed

Description

Called when an autoDJ cannot be restarted after an outage

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('source-outage-restart-failed',array(&$this,'handle_sourceoutagerestartfailed'));
    }

    /**
     * Handles the source-outage-restart-failed event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_sourceoutagerestartfailed($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: app-outage-restarted

Description

Called when a supplemental application is restarted due to an outage

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('app-outage-restarted',array(&$this,'handle_appoutagerestarted'));
    }

    /**
     * Handles the app-outage-restarted event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_appoutagerestarted($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: app-outage-restart-failed

Description

Called when a supplemental application cannot be restarted after an outage

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('app-outage-restart-failed',array(&$this,'handle_appoutagerestartfailed'));
    }

    /**
     * Handles the app-outage-restart-failed event
     *
     * @param string $username the username of the account
     *
     * @return int always returns PluginHooks::OK
     */
    public function handle_appoutagerestartfailed($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            /* swallow the exception */
        }
        return PluginHooks::OK;
    }

}

Event: bitrate-exceeded

Description

Called when a stream is broadcasting in excess of its configured bit rate limit.

Parameters

The following parameters are passed, in the order shown, to this script:

  • username (string)
    the username of the account

Return Value

Returning PluginHooks::OK causes the event to proceed normally.

Returning PluginHooks::COMPLETE prevents any further event handlers from running and causes the event to proceed normally.

Returning PluginHooks::ERROR prevents the event from running. The handler may also specify an error message by calling $this->set_error() with the error string.

For this event, aborting prevents the bit rate limit from being enforced and allows the stream to continue broadcasting.

Sample Code

<?php
class PluginHooks_myplugin extends PluginHooks {

    public function install_hooks() {
        PluginHooks::register('bitrate-exceeded',array(&$this,'handle_bitrateexceeded'));
    }

    /**
     * Handles the bitrate-exceeded event
     *
     * @param string $username the username of the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
    public function handle_bitrateexceeded($username) {
        try {
            /* implementation details here ... */
        } catch (Exception $e) {
            $this->set_error($e->getMessage());
            return PluginHooks::ERROR;
        }
        return PluginHooks::OK;
    }

}

Previous: Plugins
Section: Plugins