Clean up logging
This commit is contained in:
parent
cb64bc3213
commit
c025456bdd
|
@ -40,7 +40,7 @@ export function boot(ds: Ref, debug: boolean = false) {
|
||||||
|
|
||||||
function tryConnection(addr: G.RelayAddress): Promise<WebSocket> {
|
function tryConnection(addr: G.RelayAddress): Promise<WebSocket> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
console.log('trying', addr);
|
console.log('@syndicate-lang/ws-relay trying', addr);
|
||||||
const ws = new WebSocket(addr.url);
|
const ws = new WebSocket(addr.url);
|
||||||
ws.binaryType = 'arraybuffer';
|
ws.binaryType = 'arraybuffer';
|
||||||
ws.onopen = () => resolve(ws);
|
ws.onopen = () => resolve(ws);
|
||||||
|
@ -57,31 +57,28 @@ export function boot(ds: Ref, debug: boolean = false) {
|
||||||
try {
|
try {
|
||||||
return { ws: await tryConnection(addr), addr };
|
return { ws: await tryConnection(addr), addr };
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('attempt to contact', addr.url, 'failed with', e);
|
console.log(
|
||||||
|
'@syndicate-lang/ws-relay attempt to contact', addr.url, 'failed with', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function wsConnect(addrs: G.RelayAddress[], k: (e: Ref, addr: G.RelayAddress) => void) {
|
function wsConnect(addrs: G.RelayAddress[], k: (e: Ref, addr: G.RelayAddress) => void) {
|
||||||
console.log('wsConnect', addrs);
|
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
new Supervisor({
|
new Supervisor({
|
||||||
restartPolicy: SupervisorRestartPolicy.ALWAYS,
|
restartPolicy: SupervisorRestartPolicy.ALWAYS,
|
||||||
}, () => ['wsRelay', fromJS(addrs), counter++], () => {
|
}, () => ['wsRelay', fromJS(addrs), counter++], () => {
|
||||||
console.log('try!', counter - 1);
|
|
||||||
const facet = Turn.activeFacet;
|
const facet = Turn.activeFacet;
|
||||||
facet.preventInertCheck();
|
facet.preventInertCheck();
|
||||||
|
|
||||||
establishConnection(addrs).then(result => facet.turn(() => {
|
establishConnection(addrs).then(result => facet.turn(() => {
|
||||||
if (result === null) {
|
if (result === null) {
|
||||||
console.log('no successful connection');
|
console.log('@syndicate-lang/ws-relay no successful connection');
|
||||||
stop {}
|
stop {}
|
||||||
} else {
|
} else {
|
||||||
const {ws, addr} = result;
|
const {ws, addr} = result;
|
||||||
console.log('hey cool', addr);
|
|
||||||
on stop {
|
on stop {
|
||||||
console.log('on stop triggered');
|
|
||||||
ws.close();
|
ws.close();
|
||||||
}
|
}
|
||||||
ws.onclose = () => facet.turn(() => { stop {} });
|
ws.onclose = () => facet.turn(() => { stop {} });
|
||||||
|
@ -104,7 +101,6 @@ export function boot(ds: Ref, debug: boolean = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolve(e: Ref, steps: N.RouteStep<Ref>[], k: (e: Ref) => void) {
|
function resolve(e: Ref, steps: N.RouteStep<Ref>[], k: (e: Ref) => void) {
|
||||||
console.log('resolve', e, steps);
|
|
||||||
if (steps.length === 0) {
|
if (steps.length === 0) {
|
||||||
k(e);
|
k(e);
|
||||||
} else {
|
} else {
|
||||||
|
@ -155,7 +151,6 @@ export function boot(ds: Ref, debug: boolean = false) {
|
||||||
remoteStaticPublicKey: underlying(spec.key),
|
remoteStaticPublicKey: underlying(spec.key),
|
||||||
preSharedKeys: preSharedKeys.map(underlying),
|
preSharedKeys: preSharedKeys.map(underlying),
|
||||||
});
|
});
|
||||||
console.log('HANDSHAKE', H);
|
|
||||||
let transportState: SaltyCrypto.TransportState | null = null;
|
let transportState: SaltyCrypto.TransportState | null = null;
|
||||||
let responderSession: Ref | null = null;
|
let responderSession: Ref | null = null;
|
||||||
let relay: Relay.Relay | null = null;
|
let relay: Relay.Relay | null = null;
|
||||||
|
|
Loading…
Reference in New Issue