The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

OpenTok::API - Perl SDK for OpenTok http://www.tokbox.com/

VERSION

Version 0.02

SYNOPSIS

1. Generate Token

use OpenTok::API;

# Get your own API-keys from http://www.tokbox.com/opentok/api/tools/js/apikey
my $ot = OpenTok::API->new('api_key' => '1127', 'api_secret' => '123456789sosecretcode123123123');

print $ot->generate_token()."\n";
...

2. Create new session

print $ot->create_session('location' => '127.0.0.1')->getSessionId();

SUBROUTINES/METHODS

new

Creates and returns a new OpenTok::API object

my $ot = OpenTok::API->new('api_key' => '1127', 'api_secret' => '123456789sosecretcode123123123');
  • api_key => string

    Sets your TokBox API Partner Key

  • api_secret => string

    Sets your TokBox API Partner Secret

  • mode => "development|"production"

    Set it to "production" when you launch your app in production. Default is "development".

generate_token

Generates a token for specific session.

$ot->generate_token(session_id => '153975e9d3ecce1d11baddd2c9d8d3c9d147df18', role => 'moderator' );
  • session_id => string

    If session_id is not blank, this token can only join the call with the specified session_id.

  • role => "subscriber"|"publisher"|"moderator"

    One of the roles. Default is publisher, look in the documentation to learn more about roles. http://www.tokbox.com/opentok/api/tools/as3/documentation/overview/token_creation.html

  • expire_time => int

    Optional. The time when the token will expire, defined as an integer value for a Unix timestamp (in seconds). If you do not specify this value, tokens expire in 24 hours after being created. The expiration_time value, if specified, must be within seven days of the creation time.

create_session

Creates and returns OpenTok::API::Session object

$ot->create_session(location => $ENV{'REMOTE_ADDR'});
  • location => string

    An IP address that TokBox will use to situate the session in its global network. Ideally, this IP address should be representative of the geographical locations of the participants in the session. If you have access to the IP address of the first participant in the session, use that address.

  • echoSuppression_enabled => [0|1]

    Whether echo suppression is initially enabled for multiplexed streams. The default value is 0.

  • multiplexer_numOutputStreams => int

    The number of multiplexed streams automatically created for the session. The default value is 0.

  • multiplexer_switchType => int

    An integer defining the type of multiplexer-based switch: 0 for a timeout-based switch; 1 for an activity-based switch. The default value is 0 (timeout-based).

  • multiplexer_switchTimeout => int

    The length, in milliseconds, for the switch in a timeout-based multiplexer. The minimum value is 2000 (2 seconds), and the server will change lower values to 2000. The default value is 5000 (5 seconds).

    Created OpenTok::API::Session object includes a sessionID method, which returns the session ID for the new session. Use this session ID in JavaScript on the page that you serve to the client. The JavaScript will use this value when calling the connect() method of the Session object (to connect a user to an OpenTok session).

AUTHOR

Maxim Nikolenko, <root at zbsd.ru>

BUGS

Please report any bugs or feature requests to bug-opentok-api at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=OpenTok::API. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc OpenTok::API

You can also look for information at:

http://www.tokbox.com/opentok/api/tools/as3/documentation/overview/index.html

LICENSE AND COPYRIGHT

Copyright 2011 Maxim Nikolenko.

This module is released under the following license: BSD