Skip to content

Commit

Permalink
should connect test passing
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveMieskoski committed Jan 10, 2020
1 parent de0364b commit 0f1dbc1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/WebRtcCommunication.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isBrowser } from 'browser-or-node';
import uuid from 'uuid/v4';
import MewConnectCommon from './MewConnectCommon';

const debug = debugLogger('MEWconnect:initiator');
const debug = debugLogger('MEWconnect:webRTC-communication');
const debugPeer = debugLogger('MEWconnectVerbose:peer-instances');
const debugStages = debugLogger('MEWconnect:initiator-stages');
const logger = createLogger('MewConnectInitiator');
Expand Down
22 changes: 18 additions & 4 deletions src/socketVersions/MewConnectInitiator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MewConnectInitiatorV1 from './MewConnectInitiatorV1';

import WebRtcCommunication from '../WebRtcCommunication';

const debug = debugLogger('MEWconnect:initiator');
const debug = debugLogger('MEWconnect:initiator-base');
const debugPeer = debugLogger('MEWconnectVerbose:peer-instances');
const debugStages = debugLogger('MEWconnect:initiator-stages');
const logger = createLogger('MewConnectInitiator');
Expand Down Expand Up @@ -179,6 +179,7 @@ Keys
debug('this.signed', this.signed);
}


// TODO change this to handle supplying urls at time point
async initiatorStart(url, testPrivate) {
this.generateKeys(testPrivate);
Expand All @@ -190,10 +191,18 @@ Keys
uiCommunicator: this.uiCommunicator.bind(this),
webRtcCommunication: this.webRtcCommunication
};
this.webRtcCommunication.on('data', this.dataReceived.bind(this));
this.webRtcCommunication.on('address', (data) => console.log('address webrtc', data));
this.V1 = new MewConnectInitiatorV1({ url: this.v1Url, ...options });
this.V2 = new MewConnectInitiatorV2({ url: this.v2Url, ...options });
await this.V1.initiatorStart(this.v1Url, this.mewCrypto, {signed: this.signed, connId: this.connId});
await this.V2.initiatorStart(this.v2Url, this.mewCrypto, {signed: this.signed, connId: this.connId});
await this.V1.initiatorStart(this.v1Url, this.mewCrypto, {
signed: this.signed,
connId: this.connId
});
await this.V2.initiatorStart(this.v2Url, this.mewCrypto, {
signed: this.signed,
connId: this.connId
});
}

beginRtcSequence(source, data) {
Expand All @@ -209,7 +218,12 @@ Keys
}

async rtcSend(arg) {
this.webRtcCommunication.rtcSend(arg)
this.webRtcCommunication.rtcSend(arg);
}

dataReceived(data) {
debug('dataReceived', data);
this.uiCommunicator(data.type, data.data)
}

}
2 changes: 1 addition & 1 deletion src/socketVersions/MewConnectInitiatorPror.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import MewConnectCrypto from '../MewConnectCrypto';
import MewConnectInitiatorV2 from './MewConnectInitiatorV2';
import io from 'socket.io-client';

const debug = debugLogger('MEWconnect:initiator');
const debug = debugLogger('MEWconnect:initiator-old');
const debugPeer = debugLogger('MEWconnectVerbose:peer-instances');
const debugStages = debugLogger('MEWconnect:initiator-stages');
const logger = createLogger('MewConnectInitiator');
Expand Down
2 changes: 1 addition & 1 deletion src/socketVersions/MewConnectInitiatorV1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import wrtc from 'wrtc';
import io from 'socket.io-client';
import MewConnectCommon from '../MewConnectCommon';

const debug = debugLogger('MEWconnect:initiator');
const debug = debugLogger('MEWconnect:initiator-V1');
const debugPeer = debugLogger('MEWconnectVerbose:peer-instances');
// const debugStages = debugLogger('MEWconnect:initiator-stages');
const debugStages = console.log;
Expand Down
7 changes: 4 additions & 3 deletions src/socketVersions/MewConnectInitiatorV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import MewConnectCommon from '../MewConnectCommon';
import MewConnectCrypto from '../MewConnectCrypto';
import WebRtcCommunication from '../WebRtcCommunication';

const debug = debugLogger('MEWconnect:initiator');
const debug = debugLogger('MEWconnect:initiator-V2');
const debugPeer = debugLogger('MEWconnectVerbose:peer-instances');
const debugStages = debugLogger('MEWconnect:initiator-stages');
const logger = createLogger('MewConnectInitiator');
Expand Down Expand Up @@ -38,12 +38,13 @@ export default class MewConnectInitiatorV2 extends MewConnectCommon {
this.iceState = '';
this.turnServers = [];



// this.Peer = options.wrtc || SimplePeer; //WebRTCConnection
// this.webRtcCommunication = new WebRtcCommunication();
// this.mewCrypto = options.cryptoImpl || MewConnectCrypto.create();

this.socket = new WebSocket();
this.io = io;
// this.io = io;
this.connPath = '';

this.signals = this.jsonDetails.signals;
Expand Down
7 changes: 7 additions & 0 deletions test/integration/basic.pairing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ describe('Pairing', () => {

// Receiver //

initiator.on('address', (data) => {
if(!silent) console.log('address', data); // todo remove dev item
// initiator.rtcSend({ type: 'address', data: '' });
});

await receiver.setKeys(
initiator.publicKey,
initiator.privateKey,
Expand Down Expand Up @@ -159,6 +164,8 @@ describe('Pairing', () => {
initiator.rtcSend({ type: 'address', data: '' });
});



} catch (e) {
// console.log(e); // todo remove dev item
done.fail(e);
Expand Down

0 comments on commit 0f1dbc1

Please sign in to comment.