Fix variable names.

Fix module export to be more consistent.
pull/160/head
Mikunj 6 years ago
parent ddbbb1a6f0
commit 3c07d99a89

@ -257,6 +257,4 @@ class LokiMessageAPI {
}
}
module.exports = {
LokiMessageAPI,
};
module.exports = LokiMessageAPI;

@ -19,6 +19,4 @@ class LokiP2pAPI {
}
}
module.exports = {
LokiP2pAPI,
};
module.exports = LokiP2pAPI;

@ -212,6 +212,4 @@ function HTTPError(message, providedCode, response, stack) {
return e;
}
module.exports = {
LokiSnodeAPI,
};
module.exports = LokiSnodeAPI;

@ -122,7 +122,4 @@ class WorkerInterface {
}
}
module.exports = {
WorkerInterface,
TimedOutError,
};
module.exports = WorkerInterface;

@ -87,4 +87,4 @@ class LocalLokiServer extends EventEmitter {
}
}
exports.LocalLokiServer = LocalLokiServer;
module.exports = LocalLokiServer;

@ -1,6 +1,6 @@
const axios = require('axios');
const { assert } = require('chai');
const { LocalLokiServer } = require('../../local_loki_server');
const LocalLokiServer = require('../../local_loki_server');
describe('LocalLokiServer', () => {
before(async () => {

@ -12,6 +12,9 @@
/* global ContactBuffer: false */
/* global GroupBuffer: false */
/* global WebSocketResource: false */
/* global localLokiServer: false */
/* global localServerPort: false */
/* global lokiMessageAPI: false */
/* eslint-disable more/no-then */
/* eslint-disable no-unreachable */
@ -22,8 +25,6 @@ function MessageReceiver(username, password, signalingKey, options = {}) {
this.signalingKey = signalingKey;
this.username = username;
this.password = password;
this.lokiMessageAPI = window.LokiMessageAPI;
this.localServer = window.LocalLokiServer;
if (!options.serverTrustRoot) {
throw new Error('Server trust root is required!');
@ -68,7 +69,7 @@ MessageReceiver.prototype.extend({
}
this.hasConnected = true;
this.httpPollingResource = new HttpResource(this.lokiMessageAPI, {
this.httpPollingResource = new HttpResource(lokiMessageAPI, {
handleRequest: this.handleRequest.bind(this),
});
this.httpPollingResource.startPolling(connected => {
@ -82,10 +83,10 @@ MessageReceiver.prototype.extend({
}
});
this.localServer.start(window.localServerPort).then(port => {
localLokiServer.start(localServerPort).then(port => {
window.log.info(`Local Server started at localhost:${port}`);
window.libloki.api.broadcastOnlineStatus();
this.localServer.on('message', this.httpPollingResource.handleMessage);
libloki.api.broadcastOnlineStatus();
localLokiServer.on('message', this.httpPollingResource.handleMessage);
});
// TODO: Rework this socket stuff to work with online messaging
@ -130,12 +131,11 @@ MessageReceiver.prototype.extend({
this.wsr = null;
}
if (this.localServer) {
this.localServer.removeListener(
if (localLokiServer) {
localLokiServer.removeListener(
'message',
this.httpPollingResource.handleMessage
);
this.localServer = null;
}
},
close() {
@ -148,8 +148,8 @@ MessageReceiver.prototype.extend({
this.wsr.close(3000, 'called close');
}
if (this.localServer) {
this.localServer.close();
if (localLokiServer) {
localLokiServer.close();
}
return this.drain();
@ -900,7 +900,7 @@ MessageReceiver.prototype.extend({
},
async handleLokiAddressMessage(envelope, lokiAddressMessage) {
const { p2pAddress, p2pPort } = lokiAddressMessage;
window.LokiP2pAPI.addContactP2pDetails(
window.lokiP2pAPI.addContactP2pDetails(
envelope.source,
p2pAddress,
p2pPort

@ -34,8 +34,6 @@ function OutgoingMessage(
this.callback = callback;
this.silent = silent;
this.lokiMessageAPI = window.LokiMessageAPI;
this.numbersCompleted = 0;
this.errors = [];
this.successfulNumbers = [];
@ -186,7 +184,7 @@ OutgoingMessage.prototype = {
async transmitMessage(number, data, timestamp, ttl = 24 * 60 * 60) {
const pubKey = number;
try {
await this.lokiMessageAPI.sendMessage(pubKey, data, timestamp, ttl);
await window.lokiMessageAPI.sendMessage(pubKey, data, timestamp, ttl);
} catch (e) {
if (e.name === 'HTTPError' && (e.code !== 409 && e.code !== 410)) {
// 409 and 410 should bubble and be handled by doSendMessage

@ -269,31 +269,31 @@ window.WebAPI = initializeWebAPI({
proxyUrl: config.proxyUrl,
});
const { LokiSnodeAPI } = require('./js/modules/loki_snode_api');
const LokiSnodeAPI = require('./js/modules/loki_snode_api');
window.LokiSnodeAPI = new LokiSnodeAPI({
url: config.serverUrl,
swarmServerPort: config.swarmServerPort,
});
const { LokiP2pAPI } = require('./js/modules/loki_p2p_api');
const LokiP2pAPI = require('./js/modules/loki_p2p_api');
window.LokiP2pAPI = new LokiP2pAPI();
window.lokiP2pAPI = new LokiP2pAPI();
const { LokiMessageAPI } = require('./js/modules/loki_message_api');
const LokiMessageAPI = require('./js/modules/loki_message_api');
window.LokiMessageAPI = new LokiMessageAPI({
window.lokiMessageAPI = new LokiMessageAPI({
url: config.serverUrl,
messageServerPort: config.messageServerPort,
});
const { LocalLokiServer } = require('./libloki/local_loki_server');
const LocalLokiServer = require('./libloki/local_loki_server');
window.localServerPort = config.localServerPort;
window.LocalLokiServer = new LocalLokiServer();
window.localLokiServer = new LocalLokiServer();
window.mnemonic = require('./libloki/mnemonic');
const { WorkerInterface } = require('./js/modules/util_worker_interface');
const WorkerInterface = require('./js/modules/util_worker_interface');
// A Worker with a 3 minute timeout
const utilWorkerPath = path.join(app.getAppPath(), 'js', 'util_worker.js');

Loading…
Cancel
Save