// Generated by CoffeeScript 1.7.1
(function() {
  var BrowserWindow, EventEmitter, VoiceEngine;

  BrowserWindow = process.atomBinding('window').BrowserWindow;

  EventEmitter = require('events').EventEmitter;

  VoiceEngine = process.atomBinding('voice').VoiceEngine;

  VoiceEngine.prototype.__proto__ = EventEmitter.prototype;

  VoiceEngine.prototype.createVoiceTransport = function(userId, channelId, serverIp, port, callback) {
    this._createVoiceTransport(this, userId, channelId, serverIp, port, callback);
  };

  VoiceEngine.prototype._init = function() {
    global.static_window = BrowserWindow.getAllWindows()[0];
    this.on('_user-speaking', (function(_this) {
      return function(event, speaking, userId, channelId) {
        try {
          global.static_window.webContents.send('user-speaking', speaking, userId, channelId);
        } catch (_error) {
          console.log(_error);
          global.static_window = BrowserWindow.getAllWindows()[0];
        }
      };
    })(this));
    this.on('_on-voice', (function(_this) {
      return function(event, level) {
        try {
          global.static_window.webContents.send('on-voice', level);
        } catch (_error) {
          console.log(_error);
          global.static_window = BrowserWindow.getAllWindows()[0];
        }
      };
    })(this));
    this.on('_input-event', (function(_this) {
      return function(event, eventType, eventState, eventCode) {
        try {
          global.static_window.webContents.send('input-event', eventType, eventState, eventCode);
        } catch (_error) {
          console.log(_error);
          global.static_window = BrowserWindow.getAllWindows()[0];
        }
      };
    })(this));
  };

  VoiceEngine.root = new VoiceEngine({});

  module.exports = VoiceEngine;

}).call(this);
