Skip to content

Commit 273076d

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

File tree

11 files changed

+1438
-2
lines changed

11 files changed

+1438
-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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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, sendFinalNotify: boolean];
16+
subscribe: [isUnsubscribe: boolean, request: IncomingRequest, body: string | undefined, contentType: string | undefined];
17+
}
18+
19+
export class Notifier extends EventEmitter<MessageEventMap> {
20+
start(): void;
21+
setActiveState(): void;
22+
notify(body?: string): void;
23+
terminate(body?: string, reason?: string): void;
24+
get state(): string;
25+
get id(): string;
26+
set data(_data: any);
27+
get data(): any;
28+
static get C(): typeof NotifierTerminationReason;
29+
get C(): typeof NotifierTerminationReason;
30+
}

0 commit comments

Comments
 (0)