@pureweb/platform-streaming-agent
Version:
The PureWeb platform streaming agent enables your game to communicate and stream through the PureWeb Platform
52 lines (51 loc) • 2.05 kB
TypeScript
import { MessageEvent, ILocalAgent, Contribution, PlatformNext } from '@pureweb/platform-sdk';
import { Configuration } from 'src/Configuration';
import WebSocket from 'ws';
import { Bimap } from './bimap';
import { IConnectionService } from '../../IConnectionService';
import { ConnectionStates } from '../../ConnectionStates';
import { IPresenceMonitor } from '../presence/IPresenceMonitor';
export declare class SignallingService implements IConnectionService {
private ADDRESS_IN_USE;
agent: ILocalAgent;
platform: PlatformNext;
agentPlayerMap: Bimap<string, number>;
playerId: number;
streamerServer: WebSocket.Server;
streamerConnection: WebSocket;
contribution: Contribution;
iceCandidateMessageEvents: Map<string, MessageEvent[]>;
private connectionStateChange;
config: Configuration;
private _presenceMonitor;
constructor(agent: ILocalAgent, config: Configuration, platform: PlatformNext);
onStateChanged(handler: (state: ConnectionStates) => void): void;
/**
* Notify through agent contributions that stream is available
*/
private notifyRemoteAgentsStreamConnected;
/**
* Notifies through agent contributions that stream is not available
*/
private notifyRemoteAgentsStreamDisconnected;
/**
*
* @param streamerConnection WebSocket to unreal pixelStreaming
*/
private connect;
reconnect(): void;
stop(): void;
/**
* Starts Signalling service.
* Listens for pixel streaming connection event on streamer websocket server
* Subscribes to agent platform messages that are used as a Signalling service
*/
start: (presenceMonitor: IPresenceMonitor) => Promise<void>;
private processMessage;
/**
* Add remote agent to the map so we can match agents ids with playerIds that are passed to the unreal game pixelStreamer connection
* Note: pixelStreamer expects number hence the map since our agent ids are strings
* @param agentId
*/
private addRemoteAgentToMap;
}