Ver código fonte

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

master
Naman Jain 4 meses atrás
pai
commit
ba3415b72a
Nenhuma conta vinculada ao e-mail do autor do commit
1 arquivos alterados com 25 adições e 4 exclusões
  1. 25
    4
      modules/videosipgw/VideoSIPGW.ts

modules/videosipgw/VideoSIPGW.js → modules/videosipgw/VideoSIPGW.ts Ver arquivo

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

Carregando…
Cancelar
Salvar