Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyoshiaki committed Jan 1, 2024
1 parent 6a7f442 commit cbc9b8f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
6 changes: 5 additions & 1 deletion e2e/tests/ice/restart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ describe("ice/restart", () => {
};
channel.onmessage = async ({ data }) => {
if (data === "ping" + "pong") {
await new Promise((r) => setTimeout(r, 5000));

console.log("restartIce");

pc.restartIce();
await pc.setLocalDescription(await pc.createOffer());
const answer = await peer.request(label, {
Expand Down Expand Up @@ -126,6 +130,6 @@ describe("ice/restart", () => {
});
await pc.setRemoteDescription(answer);
}),
60_000 * 60,
15_000,
);
});
9 changes: 8 additions & 1 deletion packages/ice/src/ice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ export class Connection {
})
.find((pair) => pair.state === CandidatePairState.WAITING);
if (pair) {
log("checkStart waiting", this.remoteUsername);
pair.handle = future(this.checkStart(pair));
return true;
}
Expand All @@ -364,6 +365,7 @@ export class Connection {
(pair) => pair.state === CandidatePairState.FROZEN,
);
if (pair) {
log("checkStart frozen", this.remoteUsername);
pair.handle = future(this.checkStart(pair));
return true;
}
Expand Down Expand Up @@ -666,6 +668,7 @@ export class Connection {

resetNominatedPair() {
log("resetNominatedPair");

this.nominated = undefined;
this.nominating = false;
}
Expand Down Expand Up @@ -787,6 +790,7 @@ export class Connection {
} else if (request.attributesKeys.includes("ICE-CONTROLLING")) {
this.switchRole(false);
}
log("checkStart resolve conflict", this.remoteUsername);
await this.checkStart(pair);
r();
return;
Expand Down Expand Up @@ -838,7 +842,7 @@ export class Connection {
// 7.2. STUN Server Procedures
// 7.2.1.3、7.2.1.4、および7.2.1.5
checkIncoming(message: Message, addr: Address, protocol: Protocol) {
// log("checkIncoming", message.toJSON(), addr);
log("checkIncoming", message.toJSON());
// """
// Handle a successful incoming check.
// """
Expand Down Expand Up @@ -869,6 +873,7 @@ export class Connection {
// find pair
let pair = this.findPair(protocol, remoteCandidate);
if (!pair) {
log("checkIncoming new pair", this.remoteUsername);
pair = new CandidatePair(protocol, remoteCandidate);
this.setPairState(pair, CandidatePairState.WAITING);
this.checkList.push(pair);
Expand All @@ -881,6 +886,7 @@ export class Connection {
pair.state,
)
) {
log("checkStart triggered", this.remoteUsername);
pair.handle = future(this.checkStart(pair));
} else {
pair;
Expand Down Expand Up @@ -969,6 +975,7 @@ export class Connection {
this.state = "new";
this._localCandidatesEnd = false;
this._remoteCandidates = [];

this.nominated = undefined;
this.nominating = false;
this.checkListDone = false;
Expand Down
5 changes: 5 additions & 0 deletions packages/ice/src/turn/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class TurnTransport implements Protocol {
delete this.turn.transactions[request.transactionIdHex];
}
}
// todo
async close() {}
async connectionMade() {}
async sendData(data: Buffer, addr: Address) {
await this.turn.sendData(data, addr);
Expand Down Expand Up @@ -248,6 +250,9 @@ class TurnClient implements Protocol {
}
}

// todo
async close() {}

async sendData(data: Buffer, addr: Address) {
const channel = await this.getChannel(addr);

Expand Down
2 changes: 1 addition & 1 deletion packages/ice/src/types/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface Protocol {
) => Promise<[Message, Address]>;
responseAddr?: Address;
responseMessage?: string;
close?: () => Promise<void>;
close: () => Promise<void>;
connectionMade: (...args: any) => Promise<void>;
sendStun: (message: Message, addr: Address) => Promise<void>;
sendData: (data: Buffer, addr: Address) => Promise<void>;
Expand Down

0 comments on commit cbc9b8f

Please sign in to comment.