1 | "use strict";
|
2 |
|
3 | var events = require("events");
|
4 | var util = require("util");
|
5 | var _ = require("underscore");
|
6 | var count = 0;
|
7 |
|
8 | var ccg = module.exports = function (host, port) {
|
9 | events.EventEmitter.call(this);
|
10 |
|
11 | this.options = _.extend({}, this.options);
|
12 |
|
13 | if (typeof(host) == "string") {
|
14 | this.options.host = host;
|
15 | } else if (typeof(host) == "object") {
|
16 | _.extend(this.options, host);
|
17 | }
|
18 |
|
19 | if (port) {
|
20 | this.options.port = port;
|
21 | }
|
22 |
|
23 | this.index = count++;
|
24 | };
|
25 |
|
26 | util.inherits(ccg, events.EventEmitter);
|
27 |
|
28 | ccg.prototype.options = {
|
29 | reconnect: true,
|
30 | host: "localhost",
|
31 | port: 5250,
|
32 | debug: false
|
33 | };
|
34 |
|
35 | ccg.prototype.log = function () {
|
36 | if (!this.options.debug) return;
|
37 |
|
38 | var args = _.values(arguments);
|
39 | args.unshift("CCG" + this.index + ":");
|
40 |
|
41 | console.log.apply(console, args);
|
42 | };
|
43 |
|
44 |
|
45 | require("./lib/connection")(ccg);
|
46 |
|
47 | require("./lib/query")(ccg);
|
48 |
|
49 | require("./lib/playout")(ccg);
|
50 |
|
51 | require("./lib/data")(ccg);
|
52 |
|
53 | require("./lib/template")(ccg);
|
54 |
|
55 | require("./lib/mixer")(ccg);
|