Skip to content

Commit ba3415b

Browse files
authored
feat(ts) migrate modules\videosipgw\VideoSIPGW to TS
1 parent 01b6815 commit ba3415b

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

modules/videosipgw/VideoSIPGW.js renamed to modules/videosipgw/VideoSIPGW.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,39 @@ import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
55

66
import JitsiVideoSIPGWSession from './JitsiVideoSIPGWSession';
77
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+
}
824

925
/**
1026
* Main video SIP GW handler. Stores references of all created sessions.
1127
*/
1228
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;
1334

1435
/**
1536
* Creates new handler.
1637
*
1738
* @param {ChatRoom} chatRoom - Tha chat room to handle.
1839
*/
19-
constructor(chatRoom) {
40+
constructor(chatRoom: ChatRoom) {
2041
this.chatRoom = chatRoom;
2142
this.eventEmitter = chatRoom.eventEmitter;
2243
logger.debug('creating VideoSIPGW');
@@ -37,7 +58,7 @@ export default class VideoSIPGW {
3758
* @param {Object} node the presence node Object to handle.
3859
* Object representing part of the presence received over xmpp.
3960
*/
40-
handleJibriSIPState(node) {
61+
handleJibriSIPState(node: { attributes?: INodeAttributes; }): void {
4162
const attributes = node.attributes;
4263

4364
if (!attributes) {
@@ -84,7 +105,7 @@ export default class VideoSIPGW {
84105
* @param {string} displayName - The display name to use.
85106
* @returns {JitsiVideoSIPGWSession|Error}
86107
*/
87-
createVideoSIPGWSession(sipAddress, displayName) {
108+
createVideoSIPGWSession(sipAddress: string, displayName: string): JitsiVideoSIPGWSession | Error {
88109
if (this.sessions[sipAddress]) {
89110
logger.warn('There was already a Video SIP GW session for address',
90111
sipAddress);
@@ -108,7 +129,7 @@ export default class VideoSIPGW {
108129
*
109130
* @param {options} event - { address, oldState, newState, displayName }
110131
*/
111-
sessionStateChanged(event) {
132+
sessionStateChanged(event: ISessionStateChangeEvent): void {
112133
const address = event.address;
113134

114135
if (event.newState === Constants.STATE_OFF

0 commit comments

Comments
 (0)