Browse Source

feat(ts) migrate modules\videosipgw\VideoSIPGW to TS

master
Naman Jain 4 months ago
parent
commit
ba3415b72a
No account linked to committer's email address
1 changed files with 25 additions and 4 deletions
  1. 25
    4
      modules/videosipgw/VideoSIPGW.ts

modules/videosipgw/VideoSIPGW.js → modules/videosipgw/VideoSIPGW.ts View File

5
 
5
 
6
 import JitsiVideoSIPGWSession from './JitsiVideoSIPGWSession';
6
 import JitsiVideoSIPGWSession from './JitsiVideoSIPGWSession';
7
 import * as Constants from './VideoSIPGWConstants';
7
 import * as Constants from './VideoSIPGWConstants';
8
+import ChatRoom from '../xmpp/ChatRoom';
9
+import EventEmitter from '../util/EventEmitter';
10
+
11
+
12
+export interface ISessionStateChangeEvent {
13
+    address: string;
14
+    displayName?: string;
15
+    newState: string;
16
+    oldState?: string;
17
+}
18
+
19
+export interface INodeAttributes {
20
+    failure_reason?: string;
21
+    sipaddress?: string;
22
+    state: string;
23
+}
8
 
24
 
9
 /**
25
 /**
10
  * Main video SIP GW handler. Stores references of all created sessions.
26
  * Main video SIP GW handler. Stores references of all created sessions.
11
  */
27
  */
12
 export default class VideoSIPGW {
28
 export default class VideoSIPGW {
29
+    private chatRoom: ChatRoom;
30
+    private eventEmitter: EventEmitter;
31
+    private sessions: Record<string, JitsiVideoSIPGWSession>;
32
+    private sessionStateChangeListener: (event: ISessionStateChangeEvent) => void;
33
+    private state?: string;
13
 
34
 
14
     /**
35
     /**
15
      * Creates new handler.
36
      * Creates new handler.
16
      *
37
      *
17
      * @param {ChatRoom} chatRoom - Tha chat room to handle.
38
      * @param {ChatRoom} chatRoom - Tha chat room to handle.
18
      */
39
      */
19
-    constructor(chatRoom) {
40
+    constructor(chatRoom: ChatRoom) {
20
         this.chatRoom = chatRoom;
41
         this.chatRoom = chatRoom;
21
         this.eventEmitter = chatRoom.eventEmitter;
42
         this.eventEmitter = chatRoom.eventEmitter;
22
         logger.debug('creating VideoSIPGW');
43
         logger.debug('creating VideoSIPGW');
37
      * @param {Object} node the presence node Object to handle.
58
      * @param {Object} node the presence node Object to handle.
38
      * Object representing part of the presence received over xmpp.
59
      * Object representing part of the presence received over xmpp.
39
      */
60
      */
40
-    handleJibriSIPState(node) {
61
+    handleJibriSIPState(node: { attributes?: INodeAttributes; }): void {
41
         const attributes = node.attributes;
62
         const attributes = node.attributes;
42
 
63
 
43
         if (!attributes) {
64
         if (!attributes) {
84
      * @param {string} displayName - The display name to use.
105
      * @param {string} displayName - The display name to use.
85
      * @returns {JitsiVideoSIPGWSession|Error}
106
      * @returns {JitsiVideoSIPGWSession|Error}
86
      */
107
      */
87
-    createVideoSIPGWSession(sipAddress, displayName) {
108
+    createVideoSIPGWSession(sipAddress: string, displayName: string): JitsiVideoSIPGWSession | Error {
88
         if (this.sessions[sipAddress]) {
109
         if (this.sessions[sipAddress]) {
89
             logger.warn('There was already a Video SIP GW session for address',
110
             logger.warn('There was already a Video SIP GW session for address',
90
                 sipAddress);
111
                 sipAddress);
108
      *
129
      *
109
      * @param {options} event - { address, oldState, newState, displayName }
130
      * @param {options} event - { address, oldState, newState, displayName }
110
      */
131
      */
111
-    sessionStateChanged(event) {
132
+    sessionStateChanged(event: ISessionStateChangeEvent): void {
112
         const address = event.address;
133
         const address = event.address;
113
 
134
 
114
         if (event.newState === Constants.STATE_OFF
135
         if (event.newState === Constants.STATE_OFF

Loading…
Cancel
Save