Skip to content

Commit

Permalink
fix: handle rejected SDP exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
imarsv committed Sep 27, 2024
1 parent f8f8f80 commit b0a5aee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/connectors/IConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export type ConnectorError =
* Represents a SIP handshake error.
*/
| { type: 'ConnectorError'; name: 'SIP failed'; detail: string }
/**
* Represents access rejected error.
*/
| { type: 'ConnectorError'; name: 'Access rejected'; detail?: string }
/**
* Represents a {@link WebSocketReliableError} error
*/
Expand Down
8 changes: 6 additions & 2 deletions src/connectors/WSController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ export class WSController extends SIPConnector implements IController {

switch (ev.type) {
case 'on_answer_sdp': {
if (this._promise) {
this._promise(ev.answer_sdp);
if (ev.result === true) {
if (this._promise) {
this._promise(ev.answer_sdp);
}
} else {
this.close({ type: 'ConnectorError', name: 'Access rejected' });
}
break;
}
Expand Down

0 comments on commit b0a5aee

Please sign in to comment.