<commit_before># opentok Module

## Description

Opentok is an API to stream live video to and from your App on mobile and on the web. [Find out more online](http://www.tokbox.com/opentok/api).

## Usage

### Accessing the module

To access this module from JavaScript, you would do the following:

```javascript
var opentok = require("com.tokbox.ti.opentok");
```

The opentok variable is a reference to the Opentok module object.	

### Connecting to a Session

In order to connect to a session, we must first create a Session object and then use it to connect. In order to configure this we need an [API Key](http://www.tokbox.com/opentok/api/tools/js/apikey), a [Token](http://www.tokbox.com/opentok/api/tools/js/documentation/overview/token_creation.html), and a [Session ID](http://www.tokbox.com/opentok/api/tools/js/documentation/overview/session_creation.html).

```javascript
var CONFIG = {
  apiKey    : '...',
  token     : '...',
  sessionId : '...'
};
var session = opentok.createSession(CONFIG.sessionId);
session.connect(CONFIG.apiKey, CONFIG.token);
```

### Publishing video to the Session

To start streaming video and audio to other users/devices in the session we must Publish. To start publishing we first create a Publisher. Then to see the video that we are publishing, we add a PublisherView to the current view. All of this can only be done once the session is connected, so we place it inside the connection handler.

```javascript
var publisher, publisherView;
session.addEventListener("sessionConnected", function(event) {
  publisher = session.publish();
  publisherView = publisher.createView({ width : 320, height : 240, top : 20 });
  // self is an instance of Ti.UI.View such as ApplicationView
  self.add(publisherView);
});
```

### Subscribing to video in a Session

To start playing a video stream from another user/device in the session we must Subscribe. To start subscribing we first create a Subscriber from the Stream. Then to see the video from that Stream, we add a SubscriberView to the current view. All of this can only be done once a Stream is created (and after the session is connected), so we place it inside the stream creation handler.

```javascript
var subscriber, subscriberView;
session.addEventListener("streamCreated", function(event) {
  var stream = event.stream;<commit_msg>Update master<commit_after># opentok Module

## Description

Opentok is an API to stream live video to and from your App on mobile and on the web. [Find out more online](http://www.tokbox.com/opentok/api).

## Usage

### Accessing the module

To access this module from JavaScript, you would do the following:

```javascript
var opentok = require("com.tokbox.ti.opentok");
```

The opentok variable is a reference to the Opentok module object.	

### Connecting to a Session

In order to connect to a session, we must first create a Session object and then use it to connect. In order to configure this we need an [API Key](http://www.tokbox.com/opentok/api/tools/js/apikey), a [Token](http://www.tokbox.com/opentok/api/tools/js/documentation/overview/token_creation.html), and a [Session ID](http://www.tokbox.com/opentok/api/tools/js/documentation/overview/session_creation.html).

```javascript
var CONFIG = {
  apiKey    : '...',  // Get from Opentok website (http://www.tokbox.com/opentok/api/tools/js/apikey)
  token     : '...',  // Generated by server-side SDK
  sessionId : '...'   // Generated by server-size SDK
};
var session = opentok.createSession(CONFIG.sessionId);
session.connect(CONFIG.apiKey, CONFIG.token);
```

### Publishing video to the Session

To start streaming video and audio to other users/devices in the session we must Publish. To start publishing we first create a Publisher. Then to see the video that we are publishing, we add a PublisherView to the current view. All of this can only be done once the session is connected, so we place it inside the connection handler.

```javascript
var publisher, publisherView;
session.addEventListener("sessionConnected", function(event) {
  publisher = session.publish();
  publisherView = publisher.createView({ width : 320, height : 240, top : 20 });
  // self is an instance of Ti.UI.View such as ApplicationView
  self.add(publisherView);
});
```

### Subscribing to video in a Session

To start playing a video stream from another user/device in the session we must Subscribe. To start subscribing we first create a Subscriber from the Stream. Then to see the video from that Stream, we add a SubscriberView to the current view. All of this can only be done once a Stream is created (and after the session is connected), so we place it inside the stream creation handler.

```javascript
var subscriber, subscriberView;
session.addEventListener("streamCreated", function(event) {
  var stream = event.stream;
{'fraction_non_alphanumeric': 0.0966804979253112, 'fraction_numerical': 0.0033195020746887966, 'mean_word_length': 4.315325248070562, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 9, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1320551', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1311, 'n_words': 579}