Repository navigation
Expand file tree
/
Copy pathprocess.js
More file actions
87 lines (58 loc) · 1.88 KB
/
Copy pathprocess.js
File metadata and controls
87 lines (58 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const _ = require('lodash');
const ipcMain = require('electron').ipcMain;
const webContents = require('electron').webContents;
var Youtube;
var Facebook;
var Twitch;
function methods() {
this.messageHub = [];
};
/*
methods.prototype.addMsgToMessageHub = function ( comments ) {
this.messageHub = _.concat( this.messageHub, comments );
}
methods.prototype.sendMessageToRender = function ( ) {
// this part sorts timestamp of the msg before send to render
event.sender.send('asynchronous-reply', comments);
}
*/
var self = this;
ipcMain.on('initialization', function (event, arg) {
//console.log( arg ); //json
let platfrom = JSON.parse(arg);
if( platfrom.youtube && platfrom.youtube.length > 0){
// console.log("youtube started");
Youtube = require('./platforms/youtube')( platfrom.youtube );
}
if( platfrom.facebook && platfrom.facebook.length > 0 ){
// console.log("facebook started");
Facebook = require('./platforms/facebook')( platfrom.facebook );
}
if( platfrom.twitch && platfrom.twitch.length > 0 ){
// console.log("twitch started");
Twitch = require('./platforms/twitch')( platfrom.twitch );
Twitch.connent();
}
//send response to mainbrowser
webContents.getAllWebContents()[0].send('initialization-response');
webContents.getAllWebContents()[0].focus();
});
ipcMain.on('update-requet', function (event, arg) {
if (typeof Youtube != 'undefined') {
Youtube.getComment(function (comments) {
//console.log(comments);
//console.log( comments.length);
event.sender.send('update-reply', comments);
});
}
if (typeof Facebook != 'undefined') {
Facebook.getComment(function (comments) {
//console.log(comments);
//console.log( comments.length);
event.sender.send('update-reply', comments);
});
}
});
module.exports = function () {
return new methods();
}