openvidu/openvidu-browser/src/OpenViduInternal/Events/SignalEvent.ts

69 lines
2.1 KiB
TypeScript
Raw Normal View History

2018-04-26 15:33:47 +02:00
/*
2020-02-04 11:25:54 +01:00
* (C) Copyright 2017-2020 OpenVidu (https://openvidu.io)
2018-04-26 15:33:47 +02:00
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { Event } from './Event';
import { Connection } from '../../OpenVidu/Connection';
import { Session } from '../../OpenVidu/Session';
2018-04-26 15:33:47 +02:00
/**
* Defines the following events:
* - `signal`: dispatched by [[Session]]
* - `signal:TYPE`: dispatched by [[Session]]
*/
export class SignalEvent extends Event {
/**
* The type of signal. It is string `"signal"` for those signals sent with no [[SignalOptions.type]] property, and `"signal:type"` if was sent with a
* valid [[SignalOptions.type]] property.
2018-04-26 15:33:47 +02:00
*
* The client must be specifically subscribed to `Session.on('signal:type', function(signalEvent) {...})` to trigger that type of signal.
2018-04-26 15:33:47 +02:00
*
* Subscribing to `Session.on('signal', function(signalEvent) {...})` will trigger all signals, no matter their type.
2018-04-26 15:33:47 +02:00
*/
type: string;
/**
* The message of the signal (can be empty)
2018-04-26 15:33:47 +02:00
*/
data?: string;
2018-04-26 15:33:47 +02:00
/**
* The client that sent the signal. This property is undefined if the signal
* was directly generated by the application server (not by other client)
2018-04-26 15:33:47 +02:00
*/
from?: Connection;
2018-04-26 15:33:47 +02:00
/**
* @hidden
*/
constructor(target: Session, type: string, data?: string, from?: Connection) {
super(false, target, 'signal');
if (!!type) {
this.type = 'signal:' + type;
}
2018-04-26 15:33:47 +02:00
this.data = data;
this.from = from;
}
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() { }
2018-04-26 15:33:47 +02:00
}