Skip to content

Latest commit

 

History

History
554 lines (305 loc) · 13.2 KB

File metadata and controls

554 lines (305 loc) · 13.2 KB

@epicgames-ps/lib-pixelstreamingsignalling-ue5.5


@epicgames-ps/lib-pixelstreamingsignalling-ue5.5 / SFUConnection / SFUConnection

Class: SFUConnection

Defined in: Signalling/src/SFUConnection.ts:32

A SFU connection to the signalling server. An SFU can act as both a streamer and a player. It can subscribe to streamers like a player, and other players can subscribe to the sfu. Therefore the SFU will have a streamer id and a player id and be registered in both streamer registries and player registries.

Interesting internals: playerId: The player id of this connectiom. streamerId: The streamer id of this connection. transport: The ITransport where transport events can be subscribed to protocol: The SignallingProtocol where signalling messages can be subscribed to. streaming: True when the streamer is ready to accept subscriptions.

Extends

  • EventEmitter

Implements

Constructors

new SFUConnection()

new SFUConnection(server, ws, remoteAddress?): SFUConnection

Defined in: Signalling/src/SFUConnection.ts:63

Construct a new SFU connection.

Parameters

server

SignallingServer

The signalling server object that spawned this sfu.

ws

WebSocket

The websocket coupled to this sfu connection.

remoteAddress?

string

The remote address of this connection. Only used as display.

Returns

SFUConnection

Overrides

EventEmitter.constructor

Properties

maxSubscribers

maxSubscribers: number

Defined in: Signalling/src/SFUConnection.ts:48

Implementation of

IStreamer.maxSubscribers


playerId

playerId: string

Defined in: Signalling/src/SFUConnection.ts:34

Implementation of

IPlayer.playerId


protocol

protocol: SignallingProtocol

Defined in: Signalling/src/SFUConnection.ts:40

Implementation of

IStreamer.protocol


remoteAddress?

optional remoteAddress: string

Defined in: Signalling/src/SFUConnection.ts:46


streamerId

streamerId: string

Defined in: Signalling/src/SFUConnection.ts:36

Implementation of

IStreamer.streamerId


streaming

streaming: boolean

Defined in: Signalling/src/SFUConnection.ts:42

Implementation of

IStreamer.streaming


subscribedStreamer

subscribedStreamer: null | IStreamer

Defined in: Signalling/src/SFUConnection.ts:44

Implementation of

IPlayer.subscribedStreamer


subscribers

subscribers: Set<string>

Defined in: Signalling/src/SFUConnection.ts:50

Implementation of

IStreamer.subscribers


transport

transport: ITransport

Defined in: Signalling/src/SFUConnection.ts:38

Implementation of

IStreamer.transport

Methods

addListener()

addListener(eventName, listener): this

Defined in: Common/dist/types/Event/EventEmitter.d.ts:39

Alias for emitter.on(eventName, listener).

Parameters

eventName

string

listener

(...args) => void

Returns

this

Implementation of

IStreamer.addListener

Inherited from

EventEmitter.addListener


emit()

emit(eventName, ...args): boolean

Defined in: Common/dist/types/Event/EventEmitter.d.ts:133

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 listener

Parameters

eventName

string

args

...any[]

Returns

boolean

Implementation of

IStreamer.emit

Inherited from

EventEmitter.emit


getPlayerInfo()

getPlayerInfo(): IPlayerInfo

Defined in: Signalling/src/SFUConnection.ts:125

Returns a descriptive object for the REST API inspection operations.

Returns

IPlayerInfo

An IPlayerInfo object containing viewable information about this connection.

Implementation of

IPlayer.getPlayerInfo


getReadableIdentifier()

getReadableIdentifier(): string

Defined in: Signalling/src/SFUConnection.ts:91

Returns an identifier that is displayed in logs.

Returns

string

A string describing this connection.

Implementation of

IMessageLogger.getReadableIdentifier


getStreamerInfo()

getStreamerInfo(): IStreamerInfo

Defined in: Signalling/src/SFUConnection.ts:108

Returns a descriptive object for the REST API inspection operations.

Returns

IStreamerInfo

An IStreamerInfo object containing viewable information about this connection.

Implementation of

IStreamer.getStreamerInfo


off()

off(eventName, listener): this

Defined in: Common/dist/types/Event/EventEmitter.d.ts:88

Alias for emitter.removeListener().

Parameters

eventName

string

listener

(...args) => void

Returns

this

Implementation of

IStreamer.off

Inherited from

EventEmitter.off


on()

on(eventName, listener): this

Defined in: Common/dist/types/Event/EventEmitter.d.ts:55

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.

Parameters

eventName

string

The name of the event.

listener

(...args) => void

The callback function

Returns

this

Implementation of

IStreamer.on

Inherited from

EventEmitter.on


once()

once(eventName, listener): this

Defined in: Common/dist/types/Event/EventEmitter.d.ts:70

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.

Parameters

eventName

string

The name of the event.

listener

(...args) => void

The callback function

Returns

this

Implementation of

IStreamer.once

Inherited from

EventEmitter.once


removeAllListeners()

removeAllListeners(eventName): this

Defined in: Common/dist/types/Event/EventEmitter.d.ts:93

Removes all listeners, or those of the specified eventName. Returns a reference to the EventEmitter, so that calls can be chained.

Parameters

eventName

string

Returns

this

Implementation of

IStreamer.removeAllListeners

Inherited from

EventEmitter.removeAllListeners


removeListener()

removeListener(eventName, listener): this

Defined in: Common/dist/types/Event/EventEmitter.d.ts:84

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.

Parameters

eventName

string

listener

(...args) => void

Returns

this

Implementation of

IStreamer.removeListener

Inherited from

EventEmitter.removeListener


sendMessage()

sendMessage(message): void

Defined in: Signalling/src/SFUConnection.ts:99

Sends a signalling message to the SFU.

Parameters

message

BaseMessage

The message to send.

Returns

void

Implementation of

IStreamer.sendMessage