live-raylink
v1.0.5
Published
ray-streaming launcher for raylink
Downloads
2
Readme
Raylink RayStreaming Launcher
RayStreaming launcher
Quick start
Initial params
interface ClientInfo {
token: string // auth info
account: string // username
endpoint: string // backend socket endpoint
fingerprint: string // browser fingerprint
machineName: string // specify at will
professional: boolean // license type
}
enum LogLevel {
log = 0,
info = 1,
warn = 2,
error = 3,
}
class Sentry {
static LogLevel = LogLevel
constructor(
clientInfo: ClientInfo,
options?: {
logLevel?: LogLevel // default: LogLevel.log
dbName?: string // database name of persistence log. default: avica-log-db
},
)
}
// example
import { Sentry } from 'live-raylink'
const sentryIns = new Sentry(
{
token: 'rsat:xxxx',
account: 'anonymous',
endpoint: 'wss://raylink.live',
fingerprint: 'xxxx',
machineName: "somebody's MacBook",
professional: true,
},
{
logLevel: Sentry.LogLevel.warn,
dbName: 'awesome-db-name',
},
)
Event
use as below, payload type refers to the export type in package
sentryIns.eventBus.subscribe('event_name', handler)
| Event name | Desc | Payload |
| --------------------- | -------------------------------------------------- | ----------------------------------------------------------------------------- |
| peer_disconnected | emit when peer closed the connection | string
|
| group_received | emit when group received | GroupItem[]
|
| device_received | emit when device received | DeviceItem[]
|
| push_message | server push | PushMessage
|
| license_changed | server push | LicenseChanged
|
| connect_state_changed | emit when state changes of connection with backend | ConnectState
|
| monitor_count_changed | emit when peer monitor count changed | { count: number; deviceId: string }
|
| codec_changed | emit when peer codec options changed | { bitrate: number; framerate: number; gopLength: number; deviceId: string }
|
| ice_state_changed | emit when ICE connect state changed | { state: RTCIceConnectionState; deviceId: string }
|
| error | emit when socket/WebRTC/Logic blocked with error | { source: ErrorSource; reason: ErrorReason; code?: ValueOf<error_codeMap> }
|
Methods
prepare
import { GroupType } from 'live-raylink'
// fetch all group info
sentryIns.getGroupList()
// fetch all device info
sentryIns.getDeviceList(GroupType.Root)
// fetch device in recent sessions set
sentryIns.getDeviceList(GroupType.RecentSessions)
// change license to pro
sentryIns.changeLicense(true)
session manager
// check device if online before connecting
sentryIns
.checkDevice()
.then(() => {
console.log('continue')
})
.catch((e) => {
console.warn(e)
})
// resume connect if need admin auth
sentryIns.resumeConnectPeer('device_id', { adminAccount: 'admin_account', adminPassword: 'passwd' })
// resume connect if key miss match
sentryIns.resumeConnectPeer('device_id', { key: 'key' })
// create session
interface Options {
minBitrate: number // append x-google-min-bitrate in create offer. Default: 2000
maxBitrate: number // x-google-max-bitrate. Default: 5000
startBitrate: number // x-google-start-bitrate. Default: 4000
orientationLock: boolean // no longer auto-rotate the streaming orientation to fit the container size
iceTransportPolicy: RTCIceTransportPolicy // 'all': use all candidate, 'relay': only use 'relay' candidate. Default: 'all'
onRotate: (result: boolean) => void // invoke when every change orientation if auto-rotate enable
onPhaseChange: (phase: Phase, deltaTime: number) => void // invoke when phase change in Launcher
}
const options: Options = {}
sentryIns.createSession(hostEl, { deviceId: 'device_id', key: 'key' }, options)
feature
import { Protocol, ScaleMode } from 'live-raylink'
// hide peer device wallpaper
sentryIns.hideWallpaper('device_id')
// change video stream codec to 3000kbps/30fps on peer device
sentryIns.changeQuality('device_id', 3000, 30)
// scale screen to scaled mode on peer device
sentryIns.scaleScreen('device_id', ScaleMode.Scaled)
// switch to second monitor on peer device(if exist)
sentryIns.switchMonitor('device_id', 1)
// you can obtain monitor count by listen `monitor_count_changed` event
sentryIns.event.subscribe('monitor_count_changed', (count) => {
console.log(`current peer device has ${count} monitor`)
})
// execute REBOOT command on peer device
sentryIns.runCommand('device_id', Protocol.RunCommandType.REBOOT)
Error
all error reason can infer of ErrorReason
type in package
| Type | Desc | Source | | --------------------------------- | --------------------------- | -------- | | FAILED | | Protocol | | REFUSE | peer refuses connect | Protocol | | KEY_ERROR | key miss match | Protocol | | WAIT_CONFIRM | | Protocol | | NOT_FOUND_DEVICE | | Protocol | | REPEAT_LOGIN | | Protocol | | VERSION_TOO_LOW | | Protocol | | AUTH_FAILURE | | Protocol | | ACCOUNT_LOCKED | | Protocol | | REPEAT_REGISTER_ID | | Protocol | | DISCONNECT | | Protocol | | DEVICE_OFFLINE | | Protocol | | DEVICE_EXIST | | Protocol | | GROUP_EXIST | | Protocol | | GROUP_NOT_FOUND | | Protocol | | UNSUPPORTED_OPERATION | | Protocol | | DEVICE_NOT_ALLOW | | Protocol | | ACCOUNT_EXPIRED | | Protocol | | LEVEL_TOO_LOW | | Protocol | | VERSION_TOO_LOW_NO_FORCE | | Protocol | | DEVICE_REMOTE_CONTROL_ERROR | | Protocol | | CONNECT_NEED_VERIFY_ADMINISTRATOR | need verify administrator | Protocol | | VERIFY_ADMINISTRATOR_FAILED | administrator auth failed | Protocol | | CHANNEL_NOT_ENOUGH | channel not enough | Protocol | | CHECK_MISMATCH | peer device not for WebRTC | Boundary | | NETWORK_CHANGE | local device network change | WebRTC | | HANG_UP | peer hang up | WebRTC |