<commit_before>kd             = require 'kd'
_              = require 'lodash'
OpenTokService = require './services/opentok'
kd              = require 'kd'
_               = require 'lodash'
getNick         = require 'app/util/nick'

OpenTokService  = require './services/opentok'
ParticipantType = require './types/participant'

module.exports = class VideoCollaborationModel extends kd.Object

  defaultState:
    video              : on
    audio              : on
    publishing         : off
    connectedToSession : no
    maxConnectionCount : 999
    activeParticipant  : null

  # @param {SocialChannel} options.channel
  # @param {BaseChatVideoView} options.view
  constructor: (options = {}, data) ->

    super options, data

    @_service = OpenTokService.getInstance()
    @state = _.assign {}, options.state, @defaultState

    { @channel, @view } = options

    @session     = null
    @publisher   = null
    @stream      = null
    @subscribers = {}

    @_service.whenReady @bound 'init'


  ###*
   * Returns the view.
   *
   * @return {KDView} view
  ###
  getView: -> @view
  getChannel: -> @channel


  ###*
   * Gives the initial kick-off for video-chat process.
   *
   * @param {Function=} callback
   * @listens OpenTokService~SessionCreated
  ###
  init: (callback = kd.noop) ->

    @_service.on 'SessionCreated', @bound 'handleSessionCreated'

    @_service.connect @channel
    @subscribe()


  ###*
   * Starts publishing video.
   *
   * It ensures that OpenTokService instance
   * is ready to work via its whenReady method.
   * The options argument is just a convinient way to extend
   * publisher options when starting publishing.
   * `OpenTokService#createPublisher` has necessary defaults already.<commit_msg>video: model remove init method<commit_after>kd             = require 'kd'
_              = require 'lodash'
OpenTokService = require './services/opentok'
kd              = require 'kd'
_               = require 'lodash'
getNick         = require 'app/util/nick'

OpenTokService  = require './services/opentok'
ParticipantType = require './types/participant'

module.exports = class VideoCollaborationModel extends kd.Object

  defaultState:
    video              : on
    audio              : on
    publishing         : off
    connectedToSession : no
    maxConnectionCount : 999
    activeParticipant  : null

  # @param {SocialChannel} options.channel
  # @param {BaseChatVideoView} options.view
  constructor: (options = {}, data) ->

    super options, data

    @_service = OpenTokService.getInstance()
    @state = _.assign {}, options.state, @defaultState

    { @channel, @view } = options

    @session     = null
    @publisher   = null
    @stream      = null
    @subscribers = {}

    @_service.whenReady @bound 'init'


  ###*
   * Returns the view.
   *
   * @return {KDView} view
  ###
  getView: -> @view
  getChannel: -> @channel


  ###*
   *
  ###




  ###*
   * Starts publishing video.
   *
   * It ensures that OpenTokService instance
   * is ready to work via its whenReady method.
   * The options argument is just a convinient way to extend
   * publisher options when starting publishing.
   * `OpenTokService#createPublisher` has necessary defaults already.
{'fraction_non_alphanumeric': 0.1037037037037037, 'fraction_numerical': 0.001851851851851852, 'mean_word_length': 2.492456896551724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4883606', 'n_tokens_mistral': 973, 'n_tokens_neox': 917, 'n_words': 259}