mirror of https://github.com/jetkvm/kvm.git
Compare commits
3 Commits
cbc3f2016f
...
a916a1629f
Author | SHA1 | Date |
---|---|---|
|
a916a1629f | |
|
8e27cd6b60 | |
|
bb87fb5a1a |
|
@ -284,10 +284,6 @@ function KeyboardWrapper() {
|
||||||
preventMouseUpDefault={true}
|
preventMouseUpDefault={true}
|
||||||
stopMouseDownPropagation={true}
|
stopMouseDownPropagation={true}
|
||||||
stopMouseUpPropagation={true}
|
stopMouseUpPropagation={true}
|
||||||
physicalKeyboardHighlight={true}
|
|
||||||
physicalKeyboardHighlightPreventDefault={true}
|
|
||||||
physicalKeyboardHighlightTextColor="black"
|
|
||||||
physicalKeyboardHighlightBgColor="lightblue"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="controlArrows">
|
<div className="controlArrows">
|
||||||
|
@ -305,10 +301,6 @@ function KeyboardWrapper() {
|
||||||
preventMouseUpDefault={true}
|
preventMouseUpDefault={true}
|
||||||
stopMouseDownPropagation={true}
|
stopMouseDownPropagation={true}
|
||||||
stopMouseUpPropagation={true}
|
stopMouseUpPropagation={true}
|
||||||
physicalKeyboardHighlight={true}
|
|
||||||
physicalKeyboardHighlightPreventDefault={true}
|
|
||||||
physicalKeyboardHighlightTextColor="black"
|
|
||||||
physicalKeyboardHighlightBgColor="lightblue"
|
|
||||||
/>
|
/>
|
||||||
<Keyboard
|
<Keyboard
|
||||||
baseClass="simple-keyboard-arrows"
|
baseClass="simple-keyboard-arrows"
|
||||||
|
@ -323,10 +315,6 @@ function KeyboardWrapper() {
|
||||||
preventMouseUpDefault={true}
|
preventMouseUpDefault={true}
|
||||||
stopMouseDownPropagation={true}
|
stopMouseDownPropagation={true}
|
||||||
stopMouseUpPropagation={true}
|
stopMouseUpPropagation={true}
|
||||||
physicalKeyboardHighlight={true}
|
|
||||||
physicalKeyboardHighlightPreventDefault={true}
|
|
||||||
physicalKeyboardHighlightTextColor="black"
|
|
||||||
physicalKeyboardHighlightBgColor="lightblue"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{ /* TODO add optional number pad */ }
|
{ /* TODO add optional number pad */ }
|
||||||
|
|
15
webrtc.go
15
webrtc.go
|
@ -23,6 +23,7 @@ type Session struct {
|
||||||
HidChannel *webrtc.DataChannel
|
HidChannel *webrtc.DataChannel
|
||||||
DiskChannel *webrtc.DataChannel
|
DiskChannel *webrtc.DataChannel
|
||||||
shouldUmountVirtualMedia bool
|
shouldUmountVirtualMedia bool
|
||||||
|
rpcQueue chan webrtc.DataChannelMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
type SessionConfig struct {
|
type SessionConfig struct {
|
||||||
|
@ -106,6 +107,12 @@ func newSession(config SessionConfig) (*Session, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
session := &Session{peerConnection: peerConnection}
|
session := &Session{peerConnection: peerConnection}
|
||||||
|
session.rpcQueue = make(chan webrtc.DataChannelMessage, 256)
|
||||||
|
go func() {
|
||||||
|
for msg := range session.rpcQueue {
|
||||||
|
onRPCMessage(msg, session)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
peerConnection.OnDataChannel(func(d *webrtc.DataChannel) {
|
peerConnection.OnDataChannel(func(d *webrtc.DataChannel) {
|
||||||
scopedLogger.Info().Str("label", d.Label()).Uint16("id", *d.ID()).Msg("New DataChannel")
|
scopedLogger.Info().Str("label", d.Label()).Uint16("id", *d.ID()).Msg("New DataChannel")
|
||||||
|
@ -113,7 +120,8 @@ func newSession(config SessionConfig) (*Session, error) {
|
||||||
case "rpc":
|
case "rpc":
|
||||||
session.RPCChannel = d
|
session.RPCChannel = d
|
||||||
d.OnMessage(func(msg webrtc.DataChannelMessage) {
|
d.OnMessage(func(msg webrtc.DataChannelMessage) {
|
||||||
go onRPCMessage(msg, session)
|
// Enqueue to ensure ordered processing
|
||||||
|
session.rpcQueue <- msg
|
||||||
})
|
})
|
||||||
triggerOTAStateUpdate()
|
triggerOTAStateUpdate()
|
||||||
triggerVideoStateUpdate()
|
triggerVideoStateUpdate()
|
||||||
|
@ -189,6 +197,11 @@ func newSession(config SessionConfig) (*Session, error) {
|
||||||
if session == currentSession {
|
if session == currentSession {
|
||||||
currentSession = nil
|
currentSession = nil
|
||||||
}
|
}
|
||||||
|
// Stop RPC processor
|
||||||
|
if session.rpcQueue != nil {
|
||||||
|
close(session.rpcQueue)
|
||||||
|
session.rpcQueue = nil
|
||||||
|
}
|
||||||
if session.shouldUmountVirtualMedia {
|
if session.shouldUmountVirtualMedia {
|
||||||
if err := rpcUnmountImage(); err != nil {
|
if err := rpcUnmountImage(); err != nil {
|
||||||
scopedLogger.Warn().Err(err).Msg("unmount image failed on connection close")
|
scopedLogger.Warn().Err(err).Msg("unmount image failed on connection close")
|
||||||
|
|
Loading…
Reference in New Issue