1.0.5 • Published 5 months ago

live-raylink v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

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 nameDescPayload
peer_disconnectedemit when peer closed the connectionstring
group_receivedemit when group receivedGroupItem[]
device_receivedemit when device receivedDeviceItem[]
push_messageserver pushPushMessage
license_changedserver pushLicenseChanged
connect_state_changedemit when state changes of connection with backendConnectState
monitor_count_changedemit when peer monitor count changed{ count: number; deviceId: string }
codec_changedemit when peer codec options changed{ bitrate: number; framerate: number; gopLength: number; deviceId: string }
ice_state_changedemit when ICE connect state changed{ state: RTCIceConnectionState; deviceId: string }
erroremit 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

TypeDescSource
FAILEDProtocol
REFUSEpeer refuses connectProtocol
KEY_ERRORkey miss matchProtocol
WAIT_CONFIRMProtocol
NOT_FOUND_DEVICEProtocol
REPEAT_LOGINProtocol
VERSION_TOO_LOWProtocol
AUTH_FAILUREProtocol
ACCOUNT_LOCKEDProtocol
REPEAT_REGISTER_IDProtocol
DISCONNECTProtocol
DEVICE_OFFLINEProtocol
DEVICE_EXISTProtocol
GROUP_EXISTProtocol
GROUP_NOT_FOUNDProtocol
UNSUPPORTED_OPERATIONProtocol
DEVICE_NOT_ALLOWProtocol
ACCOUNT_EXPIREDProtocol
LEVEL_TOO_LOWProtocol
VERSION_TOO_LOW_NO_FORCEProtocol
DEVICE_REMOTE_CONTROL_ERRORProtocol
CONNECT_NEED_VERIFY_ADMINISTRATORneed verify administratorProtocol
VERIFY_ADMINISTRATOR_FAILEDadministrator auth failedProtocol
CHANNEL_NOT_ENOUGHchannel not enoughProtocol
CHECK_MISMATCHpeer device not for WebRTCBoundary
NETWORK_CHANGElocal device network changeWebRTC
HANG_UPpeer hang upWebRTC
1.0.5

5 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago

1.0.4

6 months ago

1.0.3

6 months ago

0.9.0

8 months ago

0.8.1

8 months ago

0.8.0

8 months ago

0.9.1

8 months ago

0.7.3

8 months ago

0.3.0

8 months ago

0.7.2

8 months ago

0.7.1

8 months ago

0.5.0

8 months ago

0.4.1

8 months ago

0.4.0

8 months ago

0.3.1

8 months ago

0.7.0

8 months ago

0.6.0

8 months ago

0.5.1

8 months ago

0.2.5

9 months ago

0.2.4

9 months ago

0.2.3

9 months ago

0.2.2

9 months ago

0.2.1

9 months ago

0.2.0

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago