send sequence with UDP packets (#140)
This commit is contained in:
@ -37,6 +37,10 @@ interface MouseStuff {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface MouseDrag extends MouseStuff {
|
||||||
|
sequence?: number
|
||||||
|
}
|
||||||
|
|
||||||
type uuid = string
|
type uuid = string
|
||||||
interface XYZ {
|
interface XYZ {
|
||||||
x: number
|
x: number
|
||||||
@ -67,7 +71,7 @@ interface EngineCommand {
|
|||||||
distance: number
|
distance: number
|
||||||
cap: boolean
|
cap: boolean
|
||||||
}
|
}
|
||||||
CameraDragMove?: MouseStuff
|
CameraDragMove?: MouseDrag
|
||||||
CameraDragStart?: MouseStuff
|
CameraDragStart?: MouseStuff
|
||||||
CameraDragEnd?: MouseStuff
|
CameraDragEnd?: MouseStuff
|
||||||
}
|
}
|
||||||
@ -78,6 +82,7 @@ interface EngineCommand {
|
|||||||
export class EngineCommandManager {
|
export class EngineCommandManager {
|
||||||
artifactMap: ArtifactMap = {}
|
artifactMap: ArtifactMap = {}
|
||||||
sourceRangeMap: SourceRangeMap = {}
|
sourceRangeMap: SourceRangeMap = {}
|
||||||
|
sequence = 0
|
||||||
socket?: WebSocket
|
socket?: WebSocket
|
||||||
pc?: RTCPeerConnection
|
pc?: RTCPeerConnection
|
||||||
lossyDataChannel?: RTCDataChannel
|
lossyDataChannel?: RTCDataChannel
|
||||||
@ -89,9 +94,7 @@ export class EngineCommandManager {
|
|||||||
const url = 'wss://api.dev.kittycad.io/ws/modeling/commands'
|
const url = 'wss://api.dev.kittycad.io/ws/modeling/commands'
|
||||||
this.socket = new WebSocket(url)
|
this.socket = new WebSocket(url)
|
||||||
this.pc = new RTCPeerConnection()
|
this.pc = new RTCPeerConnection()
|
||||||
this.pc.createDataChannel('unreliable_modeling_cmds', {
|
this.pc.createDataChannel('unreliable_modeling_cmds')
|
||||||
ordered: true,
|
|
||||||
})
|
|
||||||
this.socket.addEventListener('open', (event) => {
|
this.socket.addEventListener('open', (event) => {
|
||||||
console.log('Connected to websocket, waiting for ICE servers')
|
console.log('Connected to websocket, waiting for ICE servers')
|
||||||
})
|
})
|
||||||
@ -291,8 +294,10 @@ export class EngineCommandManager {
|
|||||||
console.log('socket not ready')
|
console.log('socket not ready')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ('CameraDragMove' in command.cmd && this.lossyDataChannel) {
|
if (command.cmd.CameraDragMove && this.lossyDataChannel) {
|
||||||
console.log('sending lossy command', command, this.lossyDataChannel)
|
console.log('sending lossy command', command, this.lossyDataChannel)
|
||||||
|
command.cmd.CameraDragMove.sequence = this.sequence
|
||||||
|
this.sequence++
|
||||||
this.lossyDataChannel.send(JSON.stringify(command))
|
this.lossyDataChannel.send(JSON.stringify(command))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user