@epicgames-ps/lib-pixelstreamingcommon-ue5.5
@epicgames-ps/lib-pixelstreamingcommon-ue5.5 / Protocol/SignallingProtocol / SignallingProtocol
Defined in: Protocol/SignallingProtocol.ts:27
Signalling protocol for handling messages from the signalling server.
Listen on this emitter for messages. Message type is the name of the event to listen for.
Example:
signallingProtocol.on('config', (message: Messages.config) => console.log(Got a config message: ${message})));
The transport in this class will also emit on message events.
Events emitted on transport: message: Emitted any time a message is received by the transport. Listen on this if you wish to capture all messages, rather than specific messages on 'messageHandlers'.
out: Emitted when sending a message out on the transport. Similar to 'message' but only for when messages are sent from this endpoint. Useful for debugging.
new SignallingProtocol(
transport):SignallingProtocol
Defined in: Protocol/SignallingProtocol.ts:35
transport:
ITransport
Defined in: Protocol/SignallingProtocol.ts:33
get
staticSIGNALLING_VERSION():string
Defined in: Protocol/SignallingProtocol.ts:28
string
addListener(
eventName,listener):this
Defined in: Event/EventEmitter.ts:96
Alias for emitter.on(eventName, listener).
string
(...args) => void
this
connect(
url):boolean
Defined in: Protocol/SignallingProtocol.ts:70
Asks the transport to connect to the given URL.
string
The url to connect to.
boolean
True if the connection call succeeded.
disconnect(
code?,reason?):void
Defined in: Protocol/SignallingProtocol.ts:79
Asks the transport to disconnect from any connection it might have.
number
An optional disconnection code.
string
An optional descriptive string for the disconnect reason.
void
emit(
eventName, ...args):boolean
Defined in: Event/EventEmitter.ts:262
Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments
to each.
Returns true if the event had listeners, false otherwise.
import { EventEmitter } from 'node:events';
const myEmitter = new EventEmitter();
// First listener
myEmitter.on('event', function firstListener() {
console.log('Helloooo! first listener');
});
// Second listener
myEmitter.on('event', function secondListener(arg1, arg2) {
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
});
// Third listener
myEmitter.on('event', function thirdListener(...args) {
const parameters = args.join(', ');
console.log(`event with parameters ${parameters} in third listener`);
});
console.log(myEmitter.listeners('event'));
myEmitter.emit('event', 1, 2, 3, 4, 5);
// Prints:
// [
// [Function: firstListener],
// [Function: secondListener],
// [Function: thirdListener]
// ]
// Helloooo! first listener
// event with parameters 1, 2 in second listener
// event with parameters 1, 2, 3, 4, 5 in third listenerstring
...any[]
boolean
isConnected():
boolean
Defined in: Protocol/SignallingProtocol.ts:87
Returns true if the transport is connected and ready to send/receive messages.
boolean
True if the protocol is connected.
off(
eventName,listener):this
Defined in: Event/EventEmitter.ts:196
Alias for emitter.removeListener().
string
(...args) => void
this
on(
eventName,listener):this
Defined in: Event/EventEmitter.ts:115
Adds the listener function to the end of the listeners array for the event
named eventName.
server.on('connection', (stream) => {
console.log('someone connected!');
});Returns a reference to the EventEmitter, so that calls can be chained.
string
The name of the event.
(...args) => void
The callback function
this
once(
eventName,listener):this
Defined in: Event/EventEmitter.ts:148
Adds a one-time listener function for the event named eventName. The
next time eventName is triggered, this listener is removed and then invoked.
server.once('connection', (stream) => {
console.log('Ah, we have our first user!');
});Returns a reference to the EventEmitter, so that calls can be chained.
string
The name of the event.
(...args) => void
The callback function
this
removeAllListeners(
eventName):this
Defined in: Event/EventEmitter.ts:204
Removes all listeners, or those of the specified eventName.
Returns a reference to the EventEmitter, so that calls can be chained.
string
this
EventEmitter.removeAllListeners
removeListener(
eventName,listener):this
Defined in: Event/EventEmitter.ts:188
Removes the specified listener from this EventEmitter.
const callback = (stream) => {
console.log('someone connected!');
};
server.on('connection', callback);
// ...
server.removeListener('connection', callback);Returns a reference to the EventEmitter, so that calls can be chained.
string
(...args) => void
this
sendMessage(
msg):void
Defined in: Protocol/SignallingProtocol.ts:95
Passes a message to the transport to send to the other end.
The message to send.
void