Skip to content

Commit c5160d4

Browse files
ikqorgads
authored andcommitted
Subscribe support
1 parent 6203b05 commit c5160d4

File tree

11 files changed

+1440
-2
lines changed

11 files changed

+1440
-2
lines changed

src/Constants.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export declare enum DTMF_TRANSPORT {
5757
}
5858

5959
export const REASON_PHRASE: Record<number, string>
60-
export const ALLOWED_METHODS = 'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY'
60+
export const ALLOWED_METHODS = 'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY,SUBSCRIBE'
6161
export const ACCEPTED_BODY_TYPES = 'application/sdp, application/dtmf-relay'
6262
export const MAX_FORWARDS = 69
6363
export const SESSION_EXPIRES = 90

src/Constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ module.exports = {
149149
606 : 'Not Acceptable'
150150
},
151151

152-
ALLOWED_METHODS : 'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY',
152+
ALLOWED_METHODS : 'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY,SUBSCRIBE',
153153
ACCEPTED_BODY_TYPES : 'application/sdp, application/dtmf-relay',
154154
MAX_FORWARDS : 69,
155155
SESSION_EXPIRES : 90,

src/Notifier.d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {EventEmitter} from 'events'
2+
import {IncomingRequest} from './SIPMessage'
3+
4+
declare enum NotifierTerminationReason {
5+
NOTIFY_RESPONSE_TIMEOUT = 0,
6+
NOTIFY_TRANSPORT_ERROR = 1,
7+
NOTIFY_NON_OK_RESPONSE = 2,
8+
NOTIFY_AUTHENTICATION_FAILED = 3,
9+
FINAL_NOTIFY_SENT = 4,
10+
UNSUBSCRIBE_RECEIVED = 5,
11+
SUBSCRIPTION_EXPIRED = 6
12+
}
13+
14+
export interface MessageEventMap {
15+
terminated: [terminationCode: NotifierTerminationReason];
16+
subscribe: [isUnsubscribe: boolean, request: IncomingRequest, body: string | undefined, contentType: string | undefined];
17+
expired: [];
18+
}
19+
20+
export class Notifier extends EventEmitter<MessageEventMap> {
21+
start(): void;
22+
setActiveState(): void;
23+
notify(body?: string): void;
24+
terminate(body?: string, reason?: string): void;
25+
get state(): string;
26+
get id(): string;
27+
set data(_data: any);
28+
get data(): any;
29+
static get C(): typeof NotifierTerminationReason;
30+
get C(): typeof NotifierTerminationReason;
31+
}

0 commit comments

Comments
 (0)