mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 16:55:37 +02:00
⭐ feat: Add protobuf (#171)
This is a second attempt to add protobuf to Nestri, after the first one failed --------- Co-authored-by: Philipp Neumann <3daquawolf@gmail.com> Co-authored-by: DatCaptainHorse <DatCaptainHorse@users.noreply.github.com>
This commit is contained in:
@@ -6,26 +6,27 @@ require (
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/pion/interceptor v0.1.37
|
||||
github.com/pion/webrtc/v4 v4.0.2
|
||||
github.com/pion/webrtc/v4 v4.0.8
|
||||
google.golang.org/protobuf v1.36.4
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/pion/datachannel v1.5.9 // indirect
|
||||
github.com/pion/datachannel v1.5.10 // indirect
|
||||
github.com/pion/dtls/v3 v3.0.4 // indirect
|
||||
github.com/pion/ice/v4 v4.0.2 // indirect
|
||||
github.com/pion/logging v0.2.2 // indirect
|
||||
github.com/pion/ice/v4 v4.0.5 // indirect
|
||||
github.com/pion/logging v0.2.3 // indirect
|
||||
github.com/pion/mdns/v2 v2.0.7 // indirect
|
||||
github.com/pion/randutil v0.1.0 // indirect
|
||||
github.com/pion/rtcp v1.2.14 // indirect
|
||||
github.com/pion/rtp v1.8.9 // indirect
|
||||
github.com/pion/sctp v1.8.34 // indirect
|
||||
github.com/pion/sdp/v3 v3.0.9 // indirect
|
||||
github.com/pion/rtcp v1.2.15 // indirect
|
||||
github.com/pion/rtp v1.8.11 // indirect
|
||||
github.com/pion/sctp v1.8.35 // indirect
|
||||
github.com/pion/sdp/v3 v3.0.10 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.4 // indirect
|
||||
github.com/pion/stun/v3 v3.0.0 // indirect
|
||||
github.com/pion/transport/v3 v3.0.7 // indirect
|
||||
github.com/pion/turn/v4 v4.0.0 // indirect
|
||||
github.com/wlynxg/anet v0.0.5 // indirect
|
||||
golang.org/x/crypto v0.31.0 // indirect
|
||||
golang.org/x/net v0.31.0 // indirect
|
||||
golang.org/x/sys v0.28.0 // indirect
|
||||
golang.org/x/crypto v0.32.0 // indirect
|
||||
golang.org/x/net v0.34.0 // indirect
|
||||
golang.org/x/sys v0.29.0 // indirect
|
||||
)
|
||||
|
||||
@@ -1,32 +1,33 @@
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/pion/datachannel v1.5.9 h1:LpIWAOYPyDrXtU+BW7X0Yt/vGtYxtXQ8ql7dFfYUVZA=
|
||||
github.com/pion/datachannel v1.5.9/go.mod h1:kDUuk4CU4Uxp82NH4LQZbISULkX/HtzKa4P7ldf9izE=
|
||||
github.com/pion/datachannel v1.5.10 h1:ly0Q26K1i6ZkGf42W7D4hQYR90pZwzFOjTq5AuCKk4o=
|
||||
github.com/pion/datachannel v1.5.10/go.mod h1:p/jJfC9arb29W7WrxyKbepTU20CFgyx5oLo8Rs4Py/M=
|
||||
github.com/pion/dtls/v3 v3.0.4 h1:44CZekewMzfrn9pmGrj5BNnTMDCFwr+6sLH+cCuLM7U=
|
||||
github.com/pion/dtls/v3 v3.0.4/go.mod h1:R373CsjxWqNPf6MEkfdy3aSe9niZvL/JaKlGeFphtMg=
|
||||
github.com/pion/ice/v4 v4.0.2 h1:1JhBRX8iQLi0+TfcavTjPjI6GO41MFn4CeTBX+Y9h5s=
|
||||
github.com/pion/ice/v4 v4.0.2/go.mod h1:DCdqyzgtsDNYN6/3U8044j3U7qsJ9KFJC92VnOWHvXg=
|
||||
github.com/pion/ice/v4 v4.0.5 h1:6awVfa1jg9YsI9/Lep4TG/o3kwS1Oayr5b8xz50ibJ8=
|
||||
github.com/pion/ice/v4 v4.0.5/go.mod h1:JJaoEIxUIlGDA9gaRZbwXYqI3j6VG/QchpjX+QmwN6A=
|
||||
github.com/pion/interceptor v0.1.37 h1:aRA8Zpab/wE7/c0O3fh1PqY0AJI3fCSEM5lRWJVorwI=
|
||||
github.com/pion/interceptor v0.1.37/go.mod h1:JzxbJ4umVTlZAf+/utHzNesY8tmRkM2lVmkS82TTj8Y=
|
||||
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
|
||||
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
|
||||
github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI=
|
||||
github.com/pion/logging v0.2.3/go.mod h1:z8YfknkquMe1csOrxK5kc+5/ZPAzMxbKLX5aXpbpC90=
|
||||
github.com/pion/mdns/v2 v2.0.7 h1:c9kM8ewCgjslaAmicYMFQIde2H9/lrZpjBkN8VwoVtM=
|
||||
github.com/pion/mdns/v2 v2.0.7/go.mod h1:vAdSYNAT0Jy3Ru0zl2YiW3Rm/fJCwIeM0nToenfOJKA=
|
||||
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
|
||||
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
|
||||
github.com/pion/rtcp v1.2.14 h1:KCkGV3vJ+4DAJmvP0vaQShsb0xkRfWkO540Gy102KyE=
|
||||
github.com/pion/rtcp v1.2.14/go.mod h1:sn6qjxvnwyAkkPzPULIbVqSKI5Dv54Rv7VG0kNxh9L4=
|
||||
github.com/pion/rtp v1.8.9 h1:E2HX740TZKaqdcPmf4pw6ZZuG8u5RlMMt+l3dxeu6Wk=
|
||||
github.com/pion/rtp v1.8.9/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU=
|
||||
github.com/pion/sctp v1.8.34 h1:rCuD3m53i0oGxCSp7FLQKvqVx0Nf5AUAHhMRXTTQjBc=
|
||||
github.com/pion/sctp v1.8.34/go.mod h1:yWkCClkXlzVW7BXfI2PjrUGBwUI0CjXJBkhLt+sdo4U=
|
||||
github.com/pion/sdp/v3 v3.0.9 h1:pX++dCHoHUwq43kuwf3PyJfHlwIj4hXA7Vrifiq0IJY=
|
||||
github.com/pion/sdp/v3 v3.0.9/go.mod h1:B5xmvENq5IXJimIO4zfp6LAe1fD9N+kFv+V/1lOdz8M=
|
||||
github.com/pion/rtcp v1.2.15 h1:LZQi2JbdipLOj4eBjK4wlVoQWfrZbh3Q6eHtWtJBZBo=
|
||||
github.com/pion/rtcp v1.2.15/go.mod h1:jlGuAjHMEXwMUHK78RgX0UmEJFV4zUKOFHR7OP+D3D0=
|
||||
github.com/pion/rtp v1.8.11 h1:17xjnY5WO5hgO6SD3/NTIUPvSFw/PbLsIJyz1r1yNIk=
|
||||
github.com/pion/rtp v1.8.11/go.mod h1:8uMBJj32Pa1wwx8Fuv/AsFhn8jsgw+3rUC2PfoBZ8p4=
|
||||
github.com/pion/sctp v1.8.35 h1:qwtKvNK1Wc5tHMIYgTDJhfZk7vATGVHhXbUDfHbYwzA=
|
||||
github.com/pion/sctp v1.8.35/go.mod h1:EcXP8zCYVTRy3W9xtOF7wJm1L1aXfKRQzaM33SjQlzg=
|
||||
github.com/pion/sdp/v3 v3.0.10 h1:6MChLE/1xYB+CjumMw+gZ9ufp2DPApuVSnDT8t5MIgA=
|
||||
github.com/pion/sdp/v3 v3.0.10/go.mod h1:88GMahN5xnScv1hIMTqLdu/cOcUkj6a9ytbncwMCq2E=
|
||||
github.com/pion/srtp/v3 v3.0.4 h1:2Z6vDVxzrX3UHEgrUyIGM4rRouoC7v+NiF1IHtp9B5M=
|
||||
github.com/pion/srtp/v3 v3.0.4/go.mod h1:1Jx3FwDoxpRaTh1oRV8A/6G1BnFL+QI82eK4ms8EEJQ=
|
||||
github.com/pion/stun/v3 v3.0.0 h1:4h1gwhWLWuZWOJIJR9s2ferRO+W3zA/b6ijOI6mKzUw=
|
||||
@@ -35,28 +36,23 @@ github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1
|
||||
github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo=
|
||||
github.com/pion/turn/v4 v4.0.0 h1:qxplo3Rxa9Yg1xXDxxH8xaqcyGUtbHYw4QSCvmFWvhM=
|
||||
github.com/pion/turn/v4 v4.0.0/go.mod h1:MuPDkm15nYSklKpN8vWJ9W2M0PlyQZqYt1McGuxG7mA=
|
||||
github.com/pion/webrtc/v4 v4.0.2 h1:fBwm5/hqSUybrCWl0DDBSTDrpbkcgkqpeLmXw9CsBQA=
|
||||
github.com/pion/webrtc/v4 v4.0.2/go.mod h1:moylBT2A4dNoEaYBCdV1nThM3TLwRHzWszIG+eSPaqQ=
|
||||
github.com/pion/webrtc/v4 v4.0.8 h1:T1ZmnT9qxIJIt4d8XoiMOBrTClGHDDXNg9e/fh018Qc=
|
||||
github.com/pion/webrtc/v4 v4.0.8/go.mod h1:HHBeUVBAC+j4ZFnYhovEFStF02Arb1EyD4G7e7HBTJw=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=
|
||||
github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
|
||||
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
|
||||
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
|
||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
||||
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
||||
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
|
||||
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
|
||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
|
||||
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -2,20 +2,22 @@ package relay
|
||||
|
||||
import (
|
||||
"github.com/pion/webrtc/v4"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"log"
|
||||
gen "relay/internal/proto"
|
||||
)
|
||||
|
||||
// NestriDataChannel is a custom data channel with callbacks
|
||||
type NestriDataChannel struct {
|
||||
*webrtc.DataChannel
|
||||
binaryCallbacks map[string]OnMessageCallback // MessageBase type -> callback
|
||||
callbacks map[string]OnMessageCallback // MessageBase type -> callback
|
||||
}
|
||||
|
||||
// NewNestriDataChannel creates a new NestriDataChannel from *webrtc.DataChannel
|
||||
func NewNestriDataChannel(dc *webrtc.DataChannel) *NestriDataChannel {
|
||||
ndc := &NestriDataChannel{
|
||||
DataChannel: dc,
|
||||
binaryCallbacks: make(map[string]OnMessageCallback),
|
||||
DataChannel: dc,
|
||||
callbacks: make(map[string]OnMessageCallback),
|
||||
}
|
||||
|
||||
// Handler for incoming messages
|
||||
@@ -26,14 +28,14 @@ func NewNestriDataChannel(dc *webrtc.DataChannel) *NestriDataChannel {
|
||||
}
|
||||
|
||||
// Decode message
|
||||
var base MessageBase
|
||||
if err := DecodeMessage(msg.Data, &base); err != nil {
|
||||
var base gen.ProtoMessageInput
|
||||
if err := proto.Unmarshal(msg.Data, &base); err != nil {
|
||||
log.Printf("Failed to decode binary DataChannel message, reason: %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Handle message type callback
|
||||
if callback, ok := ndc.binaryCallbacks[base.PayloadType]; ok {
|
||||
if callback, ok := ndc.callbacks["input"]; ok {
|
||||
go callback(msg.Data)
|
||||
} // TODO: Log unknown message type?
|
||||
})
|
||||
@@ -48,16 +50,16 @@ func (ndc *NestriDataChannel) SendBinary(data []byte) error {
|
||||
|
||||
// RegisterMessageCallback registers a callback for a given binary message type
|
||||
func (ndc *NestriDataChannel) RegisterMessageCallback(msgType string, callback OnMessageCallback) {
|
||||
if ndc.binaryCallbacks == nil {
|
||||
ndc.binaryCallbacks = make(map[string]OnMessageCallback)
|
||||
if ndc.callbacks == nil {
|
||||
ndc.callbacks = make(map[string]OnMessageCallback)
|
||||
}
|
||||
ndc.binaryCallbacks[msgType] = callback
|
||||
ndc.callbacks[msgType] = callback
|
||||
}
|
||||
|
||||
// UnregisterMessageCallback removes the callback for a given binary message type
|
||||
func (ndc *NestriDataChannel) UnregisterMessageCallback(msgType string) {
|
||||
if ndc.binaryCallbacks != nil {
|
||||
delete(ndc.binaryCallbacks, msgType)
|
||||
if ndc.callbacks != nil {
|
||||
delete(ndc.callbacks, msgType)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package relay
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/pion/webrtc/v4"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"log"
|
||||
gen "relay/internal/proto"
|
||||
)
|
||||
|
||||
func participantHandler(participant *Participant, room *Room) {
|
||||
@@ -54,15 +57,22 @@ func participantHandler(participant *Participant, room *Room) {
|
||||
if room.DataChannel != nil {
|
||||
// If debug mode, decode and add our timestamp, otherwise just send to room
|
||||
if GetFlags().Debug {
|
||||
var inputMsg MessageInput
|
||||
if err = DecodeMessage(data, &inputMsg); err != nil {
|
||||
var inputMsg gen.ProtoMessageInput
|
||||
if err = proto.Unmarshal(data, &inputMsg); err != nil {
|
||||
log.Printf("Failed to decode input message from participant: '%s' in room: '%s' - reason: %s\n", participant.ID, room.Name, err)
|
||||
return
|
||||
}
|
||||
inputMsg.LatencyTracker.AddTimestamp("relay_to_node")
|
||||
// Encode and send
|
||||
if data, err = EncodeMessage(inputMsg); err != nil {
|
||||
log.Printf("Failed to encode input message for participant: '%s' in room: '%s' - reason: %s\n", participant.ID, room.Name, err)
|
||||
|
||||
protoLat := inputMsg.GetMessageBase().GetLatency()
|
||||
if protoLat != nil {
|
||||
lat := LatencyTrackerFromProto(protoLat)
|
||||
lat.AddTimestamp("relay_to_node")
|
||||
protoLat = lat.ToProto()
|
||||
}
|
||||
|
||||
// Marshal and send
|
||||
if data, err = proto.Marshal(&inputMsg); err != nil {
|
||||
log.Printf("Failed to marshal input message for participant: '%s' in room: '%s' - reason: %s\n", participant.ID, room.Name, err)
|
||||
return
|
||||
}
|
||||
if err = room.DataChannel.SendBinary(data); err != nil {
|
||||
@@ -94,7 +104,7 @@ func participantHandler(participant *Participant, room *Room) {
|
||||
// ICE callback
|
||||
participant.WebSocket.RegisterMessageCallback("ice", func(data []byte) {
|
||||
var iceMsg MessageICECandidate
|
||||
if err = DecodeMessage(data, &iceMsg); err != nil {
|
||||
if err = json.Unmarshal(data, &iceMsg); err != nil {
|
||||
log.Printf("Failed to decode ICE message from participant: '%s' in room: '%s' - reason: %s\n", participant.ID, room.Name, err)
|
||||
return
|
||||
}
|
||||
@@ -120,7 +130,7 @@ func participantHandler(participant *Participant, room *Room) {
|
||||
// SDP answer callback
|
||||
participant.WebSocket.RegisterMessageCallback("sdp", func(data []byte) {
|
||||
var sdpMsg MessageSDP
|
||||
if err = DecodeMessage(data, &sdpMsg); err != nil {
|
||||
if err = json.Unmarshal(data, &sdpMsg); err != nil {
|
||||
log.Printf("Failed to decode SDP message from participant: '%s' in room: '%s' - reason: %s\n", participant.ID, room.Name, err)
|
||||
return
|
||||
}
|
||||
@@ -130,7 +140,7 @@ func participantHandler(participant *Participant, room *Room) {
|
||||
// Log callback
|
||||
participant.WebSocket.RegisterMessageCallback("log", func(data []byte) {
|
||||
var logMsg MessageLog
|
||||
if err = DecodeMessage(data, &logMsg); err != nil {
|
||||
if err = json.Unmarshal(data, &logMsg); err != nil {
|
||||
log.Printf("Failed to decode log message from participant: '%s' in room: '%s' - reason: %s\n", participant.ID, room.Name, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package relay
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/gorilla/websocket"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -81,7 +82,7 @@ func wsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// Assign message handler for join request
|
||||
ws.RegisterMessageCallback("join", func(data []byte) {
|
||||
var joinMsg MessageJoin
|
||||
if err = DecodeMessage(data, &joinMsg); err != nil {
|
||||
if err = json.Unmarshal(data, &joinMsg); err != nil {
|
||||
log.Printf("Failed to decode join message: %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package relay
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/pion/webrtc/v4"
|
||||
@@ -134,7 +135,7 @@ func ingestHandler(room *Room) {
|
||||
// ICE callback
|
||||
room.WebSocket.RegisterMessageCallback("ice", func(data []byte) {
|
||||
var iceMsg MessageICECandidate
|
||||
if err = DecodeMessage(data, &iceMsg); err != nil {
|
||||
if err = json.Unmarshal(data, &iceMsg); err != nil {
|
||||
log.Printf("Failed to decode ICE candidate message from ingest for room: '%s' - reason: %s\n", room.Name, err)
|
||||
return
|
||||
}
|
||||
@@ -165,7 +166,7 @@ func ingestHandler(room *Room) {
|
||||
// SDP offer callback
|
||||
room.WebSocket.RegisterMessageCallback("sdp", func(data []byte) {
|
||||
var sdpMsg MessageSDP
|
||||
if err = DecodeMessage(data, &sdpMsg); err != nil {
|
||||
if err = json.Unmarshal(data, &sdpMsg); err != nil {
|
||||
log.Printf("Failed to decode SDP message from ingest for room: '%s' - reason: %s\n", room.Name, err)
|
||||
return
|
||||
}
|
||||
@@ -182,7 +183,7 @@ func ingestHandler(room *Room) {
|
||||
// Log callback
|
||||
room.WebSocket.RegisterMessageCallback("log", func(data []byte) {
|
||||
var logMsg MessageLog
|
||||
if err = DecodeMessage(data, &logMsg); err != nil {
|
||||
if err = json.Unmarshal(data, &logMsg); err != nil {
|
||||
log.Printf("Failed to decode log message from ingest for room: '%s' - reason: %s\n", room.Name, err)
|
||||
return
|
||||
}
|
||||
@@ -192,7 +193,7 @@ func ingestHandler(room *Room) {
|
||||
// Metrics callback
|
||||
room.WebSocket.RegisterMessageCallback("metrics", func(data []byte) {
|
||||
var metricsMsg MessageMetrics
|
||||
if err = DecodeMessage(data, &metricsMsg); err != nil {
|
||||
if err = json.Unmarshal(data, &metricsMsg); err != nil {
|
||||
log.Printf("Failed to decode metrics message from ingest for room: '%s' - reason: %s\n", room.Name, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,20 +2,21 @@ package relay
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
gen "relay/internal/proto"
|
||||
"time"
|
||||
)
|
||||
|
||||
type TimestampEntry struct {
|
||||
Stage string `json:"stage"`
|
||||
Time string `json:"time"` // ISO 8601 string
|
||||
Stage string `json:"stage"`
|
||||
Time time.Time `json:"time"`
|
||||
}
|
||||
|
||||
// LatencyTracker provides a generic structure for measuring time taken at various stages in message processing.
|
||||
// It can be embedded in message structs for tracking the flow of data and calculating round-trip latency.
|
||||
type LatencyTracker struct {
|
||||
SequenceID string `json:"sequence_id"`
|
||||
Timestamps []TimestampEntry `json:"timestamps"`
|
||||
Metadata map[string]string `json:"metadata,omitempty"`
|
||||
SequenceID string `json:"sequence_id"`
|
||||
Timestamps []TimestampEntry `json:"timestamps"`
|
||||
}
|
||||
|
||||
// NewLatencyTracker initializes a new LatencyTracker with the given sequence ID
|
||||
@@ -23,7 +24,6 @@ func NewLatencyTracker(sequenceID string) *LatencyTracker {
|
||||
return &LatencyTracker{
|
||||
SequenceID: sequenceID,
|
||||
Timestamps: make([]TimestampEntry, 0),
|
||||
Metadata: make(map[string]string),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func (lt *LatencyTracker) AddTimestamp(stage string) {
|
||||
lt.Timestamps = append(lt.Timestamps, TimestampEntry{
|
||||
Stage: stage,
|
||||
// Ensure extremely precise UTC RFC3339 timestamps (down to nanoseconds)
|
||||
Time: time.Now().UTC().Format(time.RFC3339Nano),
|
||||
Time: time.Now().UTC(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -44,15 +44,11 @@ func (lt *LatencyTracker) TotalLatency() (int64, error) {
|
||||
|
||||
var earliest, latest time.Time
|
||||
for _, ts := range lt.Timestamps {
|
||||
t, err := time.Parse(time.RFC3339, ts.Time)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
if earliest.IsZero() || ts.Time.Before(earliest) {
|
||||
earliest = ts.Time
|
||||
}
|
||||
if earliest.IsZero() || t.Before(earliest) {
|
||||
earliest = t
|
||||
}
|
||||
if latest.IsZero() || t.After(latest) {
|
||||
latest = t
|
||||
if latest.IsZero() || ts.Time.After(latest) {
|
||||
latest = ts.Time
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,14 +63,13 @@ func (lt *LatencyTracker) PainPoints(threshold time.Duration) []string {
|
||||
|
||||
for _, ts := range lt.Timestamps {
|
||||
stage := ts.Stage
|
||||
t := ts.Time
|
||||
if lastStage == "" {
|
||||
lastStage = stage
|
||||
lastTime, _ = time.Parse(time.RFC3339, t)
|
||||
lastTime = ts.Time
|
||||
continue
|
||||
}
|
||||
|
||||
currentTime, _ := time.Parse(time.RFC3339, t)
|
||||
currentTime := ts.Time
|
||||
if currentTime.Sub(lastTime) > threshold {
|
||||
painPoints = append(painPoints, fmt.Sprintf("%s -> %s", lastStage, stage))
|
||||
}
|
||||
@@ -87,7 +82,7 @@ func (lt *LatencyTracker) PainPoints(threshold time.Duration) []string {
|
||||
|
||||
// StageLatency calculates the time taken between two specific stages.
|
||||
func (lt *LatencyTracker) StageLatency(startStage, endStage string) (time.Duration, error) {
|
||||
startTime, endTime := "", ""
|
||||
var startTime, endTime time.Time
|
||||
for _, ts := range lt.Timestamps {
|
||||
if ts.Stage == startStage {
|
||||
startTime = ts.Time
|
||||
@@ -97,18 +92,41 @@ func (lt *LatencyTracker) StageLatency(startStage, endStage string) (time.Durati
|
||||
}
|
||||
}
|
||||
|
||||
if startTime == "" || endTime == "" {
|
||||
/*if startTime == "" || endTime == "" {
|
||||
return 0, fmt.Errorf("missing timestamps for stages: %s -> %s", startStage, endStage)
|
||||
}
|
||||
}*/
|
||||
|
||||
start, err := time.Parse(time.RFC3339, startTime)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
end, err := time.Parse(time.RFC3339, endTime)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return end.Sub(start), nil
|
||||
return endTime.Sub(startTime), nil
|
||||
}
|
||||
|
||||
func LatencyTrackerFromProto(protolt *gen.ProtoLatencyTracker) *LatencyTracker {
|
||||
ret := &LatencyTracker{
|
||||
SequenceID: protolt.GetSequenceId(),
|
||||
Timestamps: make([]TimestampEntry, 0),
|
||||
}
|
||||
|
||||
for _, ts := range protolt.GetTimestamps() {
|
||||
ret.Timestamps = append(ret.Timestamps, TimestampEntry{
|
||||
Stage: ts.GetStage(),
|
||||
Time: ts.GetTime().AsTime(),
|
||||
})
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (lt *LatencyTracker) ToProto() *gen.ProtoLatencyTracker {
|
||||
ret := &gen.ProtoLatencyTracker{
|
||||
SequenceId: lt.SequenceID,
|
||||
Timestamps: make([]*gen.ProtoTimestampEntry, len(lt.Timestamps)),
|
||||
}
|
||||
|
||||
for i, timestamp := range lt.Timestamps {
|
||||
ret.Timestamps[i] = &gen.ProtoTimestampEntry{
|
||||
Stage: timestamp.Stage,
|
||||
Time: timestamppb.New(timestamp.Time),
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -1,27 +1,17 @@
|
||||
package relay
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/pion/webrtc/v4"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OnMessageCallback is a callback for binary messages of given type
|
||||
// OnMessageCallback is a callback for messages of given type
|
||||
type OnMessageCallback func(data []byte)
|
||||
|
||||
// MessageBase is the base type for WS/DC messages.
|
||||
type MessageBase struct {
|
||||
PayloadType string `json:"payload_type"`
|
||||
LatencyTracker LatencyTracker `json:"latency_tracker,omitempty"`
|
||||
}
|
||||
|
||||
// MessageInput represents an input message.
|
||||
type MessageInput struct {
|
||||
MessageBase
|
||||
Data string `json:"data"`
|
||||
PayloadType string `json:"payload_type"`
|
||||
Latency *LatencyTracker `json:"latency,omitempty"`
|
||||
}
|
||||
|
||||
// MessageLog represents a log message.
|
||||
@@ -93,50 +83,6 @@ type MessageAnswer struct {
|
||||
AnswerType AnswerType `json:"answer_type"`
|
||||
}
|
||||
|
||||
// EncodeMessage encodes a message to be sent with gzip compression
|
||||
func EncodeMessage(msg interface{}) ([]byte, error) {
|
||||
// Marshal the message to JSON
|
||||
data, err := json.Marshal(msg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to encode message: %w", err)
|
||||
}
|
||||
|
||||
// Gzip compress the JSON
|
||||
var compressedData bytes.Buffer
|
||||
writer := gzip.NewWriter(&compressedData)
|
||||
_, err = writer.Write(data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to compress message: %w", err)
|
||||
}
|
||||
if err := writer.Close(); err != nil {
|
||||
return nil, fmt.Errorf("failed to finalize compression: %w", err)
|
||||
}
|
||||
|
||||
return compressedData.Bytes(), nil
|
||||
}
|
||||
|
||||
// DecodeMessage decodes a message received with gzip decompression
|
||||
func DecodeMessage(data []byte, target interface{}) error {
|
||||
// Gzip decompress the data
|
||||
reader, err := gzip.NewReader(bytes.NewReader(data))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to initialize decompression: %w", err)
|
||||
}
|
||||
defer func(reader *gzip.Reader) {
|
||||
if err = reader.Close(); err != nil {
|
||||
fmt.Printf("failed to close reader: %v\n", err)
|
||||
}
|
||||
}(reader)
|
||||
|
||||
// Decode the JSON
|
||||
err = json.NewDecoder(reader).Decode(target)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to decode message: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendLogMessageWS sends a log message to the given WebSocket connection.
|
||||
func (ws *SafeWebSocket) SendLogMessageWS(level, message string) error {
|
||||
msg := MessageLog{
|
||||
@@ -145,12 +91,7 @@ func (ws *SafeWebSocket) SendLogMessageWS(level, message string) error {
|
||||
Message: message,
|
||||
Time: time.Now().Format(time.RFC3339),
|
||||
}
|
||||
encoded, err := EncodeMessage(msg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to encode log message: %w", err)
|
||||
}
|
||||
|
||||
return ws.SendBinary(encoded)
|
||||
return ws.SendJSON(msg)
|
||||
}
|
||||
|
||||
// SendMetricsMessageWS sends a metrics message to the given WebSocket connection.
|
||||
@@ -162,12 +103,7 @@ func (ws *SafeWebSocket) SendMetricsMessageWS(usageCPU, usageMemory float64, upt
|
||||
Uptime: uptime,
|
||||
PipelineLatency: pipelineLatency,
|
||||
}
|
||||
encoded, err := EncodeMessage(msg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to encode metrics message: %w", err)
|
||||
}
|
||||
|
||||
return ws.SendBinary(encoded)
|
||||
return ws.SendJSON(msg)
|
||||
}
|
||||
|
||||
// SendICECandidateMessageWS sends an ICE candidate message to the given WebSocket connection.
|
||||
@@ -176,12 +112,7 @@ func (ws *SafeWebSocket) SendICECandidateMessageWS(candidate webrtc.ICECandidate
|
||||
MessageBase: MessageBase{PayloadType: "ice"},
|
||||
Candidate: candidate,
|
||||
}
|
||||
encoded, err := EncodeMessage(msg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to encode ICE candidate message: %w", err)
|
||||
}
|
||||
|
||||
return ws.SendBinary(encoded)
|
||||
return ws.SendJSON(msg)
|
||||
}
|
||||
|
||||
// SendSDPMessageWS sends an SDP message to the given WebSocket connection.
|
||||
@@ -190,12 +121,7 @@ func (ws *SafeWebSocket) SendSDPMessageWS(sdp webrtc.SessionDescription) error {
|
||||
MessageBase: MessageBase{PayloadType: "sdp"},
|
||||
SDP: sdp,
|
||||
}
|
||||
encoded, err := EncodeMessage(msg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to encode SDP message: %w", err)
|
||||
}
|
||||
|
||||
return ws.SendBinary(encoded)
|
||||
return ws.SendJSON(msg)
|
||||
}
|
||||
|
||||
// SendAnswerMessageWS sends an answer message to the given WebSocket connection.
|
||||
@@ -204,24 +130,5 @@ func (ws *SafeWebSocket) SendAnswerMessageWS(answer AnswerType) error {
|
||||
MessageBase: MessageBase{PayloadType: "answer"},
|
||||
AnswerType: answer,
|
||||
}
|
||||
encoded, err := EncodeMessage(msg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to encode answer message: %w", err)
|
||||
}
|
||||
|
||||
return ws.SendBinary(encoded)
|
||||
}
|
||||
|
||||
// SendInputMessageDC sends an input message to the given DataChannel connection.
|
||||
func (ndc *NestriDataChannel) SendInputMessageDC(data string) error {
|
||||
msg := MessageInput{
|
||||
MessageBase: MessageBase{PayloadType: "input"},
|
||||
Data: data,
|
||||
}
|
||||
encoded, err := EncodeMessage(msg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to encode input message: %w", err)
|
||||
}
|
||||
|
||||
return ndc.SendBinary(encoded)
|
||||
return ws.SendJSON(msg)
|
||||
}
|
||||
|
||||
203
packages/relay/internal/proto/latency_tracker.pb.go
Normal file
203
packages/relay/internal/proto/latency_tracker.pb.go
Normal file
@@ -0,0 +1,203 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.4
|
||||
// protoc (unknown)
|
||||
// source: latency_tracker.proto
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type ProtoTimestampEntry struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Stage string `protobuf:"bytes,1,opt,name=stage,proto3" json:"stage,omitempty"`
|
||||
Time *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=time,proto3" json:"time,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ProtoTimestampEntry) Reset() {
|
||||
*x = ProtoTimestampEntry{}
|
||||
mi := &file_latency_tracker_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ProtoTimestampEntry) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProtoTimestampEntry) ProtoMessage() {}
|
||||
|
||||
func (x *ProtoTimestampEntry) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_latency_tracker_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProtoTimestampEntry.ProtoReflect.Descriptor instead.
|
||||
func (*ProtoTimestampEntry) Descriptor() ([]byte, []int) {
|
||||
return file_latency_tracker_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *ProtoTimestampEntry) GetStage() string {
|
||||
if x != nil {
|
||||
return x.Stage
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ProtoTimestampEntry) GetTime() *timestamppb.Timestamp {
|
||||
if x != nil {
|
||||
return x.Time
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ProtoLatencyTracker struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
SequenceId string `protobuf:"bytes,1,opt,name=sequence_id,json=sequenceId,proto3" json:"sequence_id,omitempty"`
|
||||
Timestamps []*ProtoTimestampEntry `protobuf:"bytes,2,rep,name=timestamps,proto3" json:"timestamps,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ProtoLatencyTracker) Reset() {
|
||||
*x = ProtoLatencyTracker{}
|
||||
mi := &file_latency_tracker_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ProtoLatencyTracker) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProtoLatencyTracker) ProtoMessage() {}
|
||||
|
||||
func (x *ProtoLatencyTracker) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_latency_tracker_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProtoLatencyTracker.ProtoReflect.Descriptor instead.
|
||||
func (*ProtoLatencyTracker) Descriptor() ([]byte, []int) {
|
||||
return file_latency_tracker_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *ProtoLatencyTracker) GetSequenceId() string {
|
||||
if x != nil {
|
||||
return x.SequenceId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ProtoLatencyTracker) GetTimestamps() []*ProtoTimestampEntry {
|
||||
if x != nil {
|
||||
return x.Timestamps
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_latency_tracker_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_latency_tracker_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x15, 0x6c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x65,
|
||||
0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f,
|
||||
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f,
|
||||
0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
|
||||
0x5b, 0x0a, 0x13, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,
|
||||
0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x67, 0x65, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x61, 0x67, 0x65, 0x12, 0x2e, 0x0a, 0x04,
|
||||
0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d,
|
||||
0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x72, 0x0a, 0x13,
|
||||
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x54, 0x72, 0x61, 0x63,
|
||||
0x6b, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x5f,
|
||||
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e,
|
||||
0x63, 0x65, 0x49, 0x64, 0x12, 0x3a, 0x0a, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,
|
||||
0x70, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x45,
|
||||
0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x73,
|
||||
0x42, 0x16, 0x5a, 0x14, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
|
||||
0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
})
|
||||
|
||||
var (
|
||||
file_latency_tracker_proto_rawDescOnce sync.Once
|
||||
file_latency_tracker_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_latency_tracker_proto_rawDescGZIP() []byte {
|
||||
file_latency_tracker_proto_rawDescOnce.Do(func() {
|
||||
file_latency_tracker_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_latency_tracker_proto_rawDesc), len(file_latency_tracker_proto_rawDesc)))
|
||||
})
|
||||
return file_latency_tracker_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_latency_tracker_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_latency_tracker_proto_goTypes = []any{
|
||||
(*ProtoTimestampEntry)(nil), // 0: proto.ProtoTimestampEntry
|
||||
(*ProtoLatencyTracker)(nil), // 1: proto.ProtoLatencyTracker
|
||||
(*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp
|
||||
}
|
||||
var file_latency_tracker_proto_depIdxs = []int32{
|
||||
2, // 0: proto.ProtoTimestampEntry.time:type_name -> google.protobuf.Timestamp
|
||||
0, // 1: proto.ProtoLatencyTracker.timestamps:type_name -> proto.ProtoTimestampEntry
|
||||
2, // [2:2] is the sub-list for method output_type
|
||||
2, // [2:2] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_latency_tracker_proto_init() }
|
||||
func file_latency_tracker_proto_init() {
|
||||
if File_latency_tracker_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_latency_tracker_proto_rawDesc), len(file_latency_tracker_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_latency_tracker_proto_goTypes,
|
||||
DependencyIndexes: file_latency_tracker_proto_depIdxs,
|
||||
MessageInfos: file_latency_tracker_proto_msgTypes,
|
||||
}.Build()
|
||||
File_latency_tracker_proto = out.File
|
||||
file_latency_tracker_proto_goTypes = nil
|
||||
file_latency_tracker_proto_depIdxs = nil
|
||||
}
|
||||
207
packages/relay/internal/proto/messages.pb.go
Normal file
207
packages/relay/internal/proto/messages.pb.go
Normal file
@@ -0,0 +1,207 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.4
|
||||
// protoc (unknown)
|
||||
// source: messages.proto
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type ProtoMessageBase struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
PayloadType string `protobuf:"bytes,1,opt,name=payload_type,json=payloadType,proto3" json:"payload_type,omitempty"`
|
||||
Latency *ProtoLatencyTracker `protobuf:"bytes,2,opt,name=latency,proto3" json:"latency,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ProtoMessageBase) Reset() {
|
||||
*x = ProtoMessageBase{}
|
||||
mi := &file_messages_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ProtoMessageBase) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProtoMessageBase) ProtoMessage() {}
|
||||
|
||||
func (x *ProtoMessageBase) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_messages_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProtoMessageBase.ProtoReflect.Descriptor instead.
|
||||
func (*ProtoMessageBase) Descriptor() ([]byte, []int) {
|
||||
return file_messages_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *ProtoMessageBase) GetPayloadType() string {
|
||||
if x != nil {
|
||||
return x.PayloadType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ProtoMessageBase) GetLatency() *ProtoLatencyTracker {
|
||||
if x != nil {
|
||||
return x.Latency
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ProtoMessageInput struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
MessageBase *ProtoMessageBase `protobuf:"bytes,1,opt,name=message_base,json=messageBase,proto3" json:"message_base,omitempty"`
|
||||
Data *ProtoInput `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ProtoMessageInput) Reset() {
|
||||
*x = ProtoMessageInput{}
|
||||
mi := &file_messages_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ProtoMessageInput) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProtoMessageInput) ProtoMessage() {}
|
||||
|
||||
func (x *ProtoMessageInput) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_messages_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProtoMessageInput.ProtoReflect.Descriptor instead.
|
||||
func (*ProtoMessageInput) Descriptor() ([]byte, []int) {
|
||||
return file_messages_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *ProtoMessageInput) GetMessageBase() *ProtoMessageBase {
|
||||
if x != nil {
|
||||
return x.MessageBase
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ProtoMessageInput) GetData() *ProtoInput {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_messages_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_messages_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x0e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0b, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x6c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x74, 0x72,
|
||||
0x61, 0x63, 0x6b, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6b, 0x0a, 0x10, 0x50,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x12,
|
||||
0x21, 0x0a, 0x0c, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x79,
|
||||
0x70, 0x65, 0x12, 0x34, 0x0a, 0x07, 0x6c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x4c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x52,
|
||||
0x07, 0x6c, 0x61, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x22, 0x76, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x3a, 0x0a,
|
||||
0x0c, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, 0x0b, 0x6d, 0x65,
|
||||
0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x04, 0x64, 0x61, 0x74,
|
||||
0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
|
||||
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61,
|
||||
0x42, 0x16, 0x5a, 0x14, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
|
||||
0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
})
|
||||
|
||||
var (
|
||||
file_messages_proto_rawDescOnce sync.Once
|
||||
file_messages_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_messages_proto_rawDescGZIP() []byte {
|
||||
file_messages_proto_rawDescOnce.Do(func() {
|
||||
file_messages_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_messages_proto_rawDesc), len(file_messages_proto_rawDesc)))
|
||||
})
|
||||
return file_messages_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_messages_proto_goTypes = []any{
|
||||
(*ProtoMessageBase)(nil), // 0: proto.ProtoMessageBase
|
||||
(*ProtoMessageInput)(nil), // 1: proto.ProtoMessageInput
|
||||
(*ProtoLatencyTracker)(nil), // 2: proto.ProtoLatencyTracker
|
||||
(*ProtoInput)(nil), // 3: proto.ProtoInput
|
||||
}
|
||||
var file_messages_proto_depIdxs = []int32{
|
||||
2, // 0: proto.ProtoMessageBase.latency:type_name -> proto.ProtoLatencyTracker
|
||||
0, // 1: proto.ProtoMessageInput.message_base:type_name -> proto.ProtoMessageBase
|
||||
3, // 2: proto.ProtoMessageInput.data:type_name -> proto.ProtoInput
|
||||
3, // [3:3] is the sub-list for method output_type
|
||||
3, // [3:3] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_messages_proto_init() }
|
||||
func file_messages_proto_init() {
|
||||
if File_messages_proto != nil {
|
||||
return
|
||||
}
|
||||
file_types_proto_init()
|
||||
file_latency_tracker_proto_init()
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_messages_proto_rawDesc), len(file_messages_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_messages_proto_goTypes,
|
||||
DependencyIndexes: file_messages_proto_depIdxs,
|
||||
MessageInfos: file_messages_proto_msgTypes,
|
||||
}.Build()
|
||||
File_messages_proto = out.File
|
||||
file_messages_proto_goTypes = nil
|
||||
file_messages_proto_depIdxs = nil
|
||||
}
|
||||
713
packages/relay/internal/proto/types.pb.go
Normal file
713
packages/relay/internal/proto/types.pb.go
Normal file
@@ -0,0 +1,713 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.4
|
||||
// protoc (unknown)
|
||||
// source: types.proto
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// MouseMove message
|
||||
type ProtoMouseMove struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // Fixed value "MouseMove"
|
||||
X int32 `protobuf:"varint,2,opt,name=x,proto3" json:"x,omitempty"`
|
||||
Y int32 `protobuf:"varint,3,opt,name=y,proto3" json:"y,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ProtoMouseMove) Reset() {
|
||||
*x = ProtoMouseMove{}
|
||||
mi := &file_types_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ProtoMouseMove) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProtoMouseMove) ProtoMessage() {}
|
||||
|
||||
func (x *ProtoMouseMove) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_types_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProtoMouseMove.ProtoReflect.Descriptor instead.
|
||||
func (*ProtoMouseMove) Descriptor() ([]byte, []int) {
|
||||
return file_types_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *ProtoMouseMove) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ProtoMouseMove) GetX() int32 {
|
||||
if x != nil {
|
||||
return x.X
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ProtoMouseMove) GetY() int32 {
|
||||
if x != nil {
|
||||
return x.Y
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// MouseMoveAbs message
|
||||
type ProtoMouseMoveAbs struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // Fixed value "MouseMoveAbs"
|
||||
X int32 `protobuf:"varint,2,opt,name=x,proto3" json:"x,omitempty"`
|
||||
Y int32 `protobuf:"varint,3,opt,name=y,proto3" json:"y,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ProtoMouseMoveAbs) Reset() {
|
||||
*x = ProtoMouseMoveAbs{}
|
||||
mi := &file_types_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ProtoMouseMoveAbs) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProtoMouseMoveAbs) ProtoMessage() {}
|
||||
|
||||
func (x *ProtoMouseMoveAbs) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_types_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProtoMouseMoveAbs.ProtoReflect.Descriptor instead.
|
||||
func (*ProtoMouseMoveAbs) Descriptor() ([]byte, []int) {
|
||||
return file_types_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *ProtoMouseMoveAbs) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ProtoMouseMoveAbs) GetX() int32 {
|
||||
if x != nil {
|
||||
return x.X
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ProtoMouseMoveAbs) GetY() int32 {
|
||||
if x != nil {
|
||||
return x.Y
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// MouseWheel message
|
||||
type ProtoMouseWheel struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // Fixed value "MouseWheel"
|
||||
X int32 `protobuf:"varint,2,opt,name=x,proto3" json:"x,omitempty"`
|
||||
Y int32 `protobuf:"varint,3,opt,name=y,proto3" json:"y,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ProtoMouseWheel) Reset() {
|
||||
*x = ProtoMouseWheel{}
|
||||
mi := &file_types_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ProtoMouseWheel) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProtoMouseWheel) ProtoMessage() {}
|
||||
|
||||
func (x *ProtoMouseWheel) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_types_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProtoMouseWheel.ProtoReflect.Descriptor instead.
|
||||
func (*ProtoMouseWheel) Descriptor() ([]byte, []int) {
|
||||
return file_types_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ProtoMouseWheel) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ProtoMouseWheel) GetX() int32 {
|
||||
if x != nil {
|
||||
return x.X
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ProtoMouseWheel) GetY() int32 {
|
||||
if x != nil {
|
||||
return x.Y
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// MouseKeyDown message
|
||||
type ProtoMouseKeyDown struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // Fixed value "MouseKeyDown"
|
||||
Key int32 `protobuf:"varint,2,opt,name=key,proto3" json:"key,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ProtoMouseKeyDown) Reset() {
|
||||
*x = ProtoMouseKeyDown{}
|
||||
mi := &file_types_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ProtoMouseKeyDown) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProtoMouseKeyDown) ProtoMessage() {}
|
||||
|
||||
func (x *ProtoMouseKeyDown) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_types_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProtoMouseKeyDown.ProtoReflect.Descriptor instead.
|
||||
func (*ProtoMouseKeyDown) Descriptor() ([]byte, []int) {
|
||||
return file_types_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *ProtoMouseKeyDown) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ProtoMouseKeyDown) GetKey() int32 {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// MouseKeyUp message
|
||||
type ProtoMouseKeyUp struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // Fixed value "MouseKeyUp"
|
||||
Key int32 `protobuf:"varint,2,opt,name=key,proto3" json:"key,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ProtoMouseKeyUp) Reset() {
|
||||
*x = ProtoMouseKeyUp{}
|
||||
mi := &file_types_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ProtoMouseKeyUp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProtoMouseKeyUp) ProtoMessage() {}
|
||||
|
||||
func (x *ProtoMouseKeyUp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_types_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProtoMouseKeyUp.ProtoReflect.Descriptor instead.
|
||||
func (*ProtoMouseKeyUp) Descriptor() ([]byte, []int) {
|
||||
return file_types_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *ProtoMouseKeyUp) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ProtoMouseKeyUp) GetKey() int32 {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// KeyDown message
|
||||
type ProtoKeyDown struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // Fixed value "KeyDown"
|
||||
Key int32 `protobuf:"varint,2,opt,name=key,proto3" json:"key,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ProtoKeyDown) Reset() {
|
||||
*x = ProtoKeyDown{}
|
||||
mi := &file_types_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ProtoKeyDown) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProtoKeyDown) ProtoMessage() {}
|
||||
|
||||
func (x *ProtoKeyDown) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_types_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProtoKeyDown.ProtoReflect.Descriptor instead.
|
||||
func (*ProtoKeyDown) Descriptor() ([]byte, []int) {
|
||||
return file_types_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *ProtoKeyDown) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ProtoKeyDown) GetKey() int32 {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// KeyUp message
|
||||
type ProtoKeyUp struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // Fixed value "KeyUp"
|
||||
Key int32 `protobuf:"varint,2,opt,name=key,proto3" json:"key,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ProtoKeyUp) Reset() {
|
||||
*x = ProtoKeyUp{}
|
||||
mi := &file_types_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ProtoKeyUp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProtoKeyUp) ProtoMessage() {}
|
||||
|
||||
func (x *ProtoKeyUp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_types_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProtoKeyUp.ProtoReflect.Descriptor instead.
|
||||
func (*ProtoKeyUp) Descriptor() ([]byte, []int) {
|
||||
return file_types_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *ProtoKeyUp) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ProtoKeyUp) GetKey() int32 {
|
||||
if x != nil {
|
||||
return x.Key
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Union of all Input types
|
||||
type ProtoInput struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Types that are valid to be assigned to InputType:
|
||||
//
|
||||
// *ProtoInput_MouseMove
|
||||
// *ProtoInput_MouseMoveAbs
|
||||
// *ProtoInput_MouseWheel
|
||||
// *ProtoInput_MouseKeyDown
|
||||
// *ProtoInput_MouseKeyUp
|
||||
// *ProtoInput_KeyDown
|
||||
// *ProtoInput_KeyUp
|
||||
InputType isProtoInput_InputType `protobuf_oneof:"input_type"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ProtoInput) Reset() {
|
||||
*x = ProtoInput{}
|
||||
mi := &file_types_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ProtoInput) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ProtoInput) ProtoMessage() {}
|
||||
|
||||
func (x *ProtoInput) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_types_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ProtoInput.ProtoReflect.Descriptor instead.
|
||||
func (*ProtoInput) Descriptor() ([]byte, []int) {
|
||||
return file_types_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *ProtoInput) GetInputType() isProtoInput_InputType {
|
||||
if x != nil {
|
||||
return x.InputType
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ProtoInput) GetMouseMove() *ProtoMouseMove {
|
||||
if x != nil {
|
||||
if x, ok := x.InputType.(*ProtoInput_MouseMove); ok {
|
||||
return x.MouseMove
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ProtoInput) GetMouseMoveAbs() *ProtoMouseMoveAbs {
|
||||
if x != nil {
|
||||
if x, ok := x.InputType.(*ProtoInput_MouseMoveAbs); ok {
|
||||
return x.MouseMoveAbs
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ProtoInput) GetMouseWheel() *ProtoMouseWheel {
|
||||
if x != nil {
|
||||
if x, ok := x.InputType.(*ProtoInput_MouseWheel); ok {
|
||||
return x.MouseWheel
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ProtoInput) GetMouseKeyDown() *ProtoMouseKeyDown {
|
||||
if x != nil {
|
||||
if x, ok := x.InputType.(*ProtoInput_MouseKeyDown); ok {
|
||||
return x.MouseKeyDown
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ProtoInput) GetMouseKeyUp() *ProtoMouseKeyUp {
|
||||
if x != nil {
|
||||
if x, ok := x.InputType.(*ProtoInput_MouseKeyUp); ok {
|
||||
return x.MouseKeyUp
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ProtoInput) GetKeyDown() *ProtoKeyDown {
|
||||
if x != nil {
|
||||
if x, ok := x.InputType.(*ProtoInput_KeyDown); ok {
|
||||
return x.KeyDown
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ProtoInput) GetKeyUp() *ProtoKeyUp {
|
||||
if x != nil {
|
||||
if x, ok := x.InputType.(*ProtoInput_KeyUp); ok {
|
||||
return x.KeyUp
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isProtoInput_InputType interface {
|
||||
isProtoInput_InputType()
|
||||
}
|
||||
|
||||
type ProtoInput_MouseMove struct {
|
||||
MouseMove *ProtoMouseMove `protobuf:"bytes,1,opt,name=mouse_move,json=mouseMove,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ProtoInput_MouseMoveAbs struct {
|
||||
MouseMoveAbs *ProtoMouseMoveAbs `protobuf:"bytes,2,opt,name=mouse_move_abs,json=mouseMoveAbs,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ProtoInput_MouseWheel struct {
|
||||
MouseWheel *ProtoMouseWheel `protobuf:"bytes,3,opt,name=mouse_wheel,json=mouseWheel,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ProtoInput_MouseKeyDown struct {
|
||||
MouseKeyDown *ProtoMouseKeyDown `protobuf:"bytes,4,opt,name=mouse_key_down,json=mouseKeyDown,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ProtoInput_MouseKeyUp struct {
|
||||
MouseKeyUp *ProtoMouseKeyUp `protobuf:"bytes,5,opt,name=mouse_key_up,json=mouseKeyUp,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ProtoInput_KeyDown struct {
|
||||
KeyDown *ProtoKeyDown `protobuf:"bytes,6,opt,name=key_down,json=keyDown,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ProtoInput_KeyUp struct {
|
||||
KeyUp *ProtoKeyUp `protobuf:"bytes,7,opt,name=key_up,json=keyUp,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*ProtoInput_MouseMove) isProtoInput_InputType() {}
|
||||
|
||||
func (*ProtoInput_MouseMoveAbs) isProtoInput_InputType() {}
|
||||
|
||||
func (*ProtoInput_MouseWheel) isProtoInput_InputType() {}
|
||||
|
||||
func (*ProtoInput_MouseKeyDown) isProtoInput_InputType() {}
|
||||
|
||||
func (*ProtoInput_MouseKeyUp) isProtoInput_InputType() {}
|
||||
|
||||
func (*ProtoInput_KeyDown) isProtoInput_InputType() {}
|
||||
|
||||
func (*ProtoInput_KeyUp) isProtoInput_InputType() {}
|
||||
|
||||
var File_types_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_types_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x0b, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x22, 0x40, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x4d, 0x6f, 0x75,
|
||||
0x73, 0x65, 0x4d, 0x6f, 0x76, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0x43, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x4d,
|
||||
0x6f, 0x75, 0x73, 0x65, 0x4d, 0x6f, 0x76, 0x65, 0x41, 0x62, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x74,
|
||||
0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12,
|
||||
0x0c, 0x0a, 0x01, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a,
|
||||
0x01, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0x41, 0x0a, 0x0f, 0x50,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x57, 0x68, 0x65, 0x65, 0x6c, 0x12, 0x12,
|
||||
0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79,
|
||||
0x70, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78,
|
||||
0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0x39,
|
||||
0x0a, 0x11, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x44,
|
||||
0x6f, 0x77, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x37, 0x0a, 0x0f, 0x50, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x55, 0x70, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
|
||||
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b,
|
||||
0x65, 0x79, 0x22, 0x34, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x4b, 0x65, 0x79, 0x44, 0x6f,
|
||||
0x77, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x32, 0x0a, 0x0a, 0x50, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x4b, 0x65, 0x79, 0x55, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65,
|
||||
0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0xab, 0x03, 0x0a,
|
||||
0x0a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x36, 0x0a, 0x0a, 0x6d,
|
||||
0x6f, 0x75, 0x73, 0x65, 0x5f, 0x6d, 0x6f, 0x76, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||
0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x4d, 0x6f, 0x75,
|
||||
0x73, 0x65, 0x4d, 0x6f, 0x76, 0x65, 0x48, 0x00, 0x52, 0x09, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x4d,
|
||||
0x6f, 0x76, 0x65, 0x12, 0x40, 0x0a, 0x0e, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x6d, 0x6f, 0x76,
|
||||
0x65, 0x5f, 0x61, 0x62, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x4d, 0x6f,
|
||||
0x76, 0x65, 0x41, 0x62, 0x73, 0x48, 0x00, 0x52, 0x0c, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x4d, 0x6f,
|
||||
0x76, 0x65, 0x41, 0x62, 0x73, 0x12, 0x39, 0x0a, 0x0b, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x77,
|
||||
0x68, 0x65, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x57, 0x68, 0x65,
|
||||
0x65, 0x6c, 0x48, 0x00, 0x52, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x57, 0x68, 0x65, 0x65, 0x6c,
|
||||
0x12, 0x40, 0x0a, 0x0e, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x64, 0x6f,
|
||||
0x77, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x44, 0x6f,
|
||||
0x77, 0x6e, 0x48, 0x00, 0x52, 0x0c, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x44, 0x6f,
|
||||
0x77, 0x6e, 0x12, 0x3a, 0x0a, 0x0c, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x5f,
|
||||
0x75, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x55, 0x70,
|
||||
0x48, 0x00, 0x52, 0x0a, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x55, 0x70, 0x12, 0x30,
|
||||
0x0a, 0x08, 0x6b, 0x65, 0x79, 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x4b, 0x65,
|
||||
0x79, 0x44, 0x6f, 0x77, 0x6e, 0x48, 0x00, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x44, 0x6f, 0x77, 0x6e,
|
||||
0x12, 0x2a, 0x0a, 0x06, 0x6b, 0x65, 0x79, 0x5f, 0x75, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x4b, 0x65,
|
||||
0x79, 0x55, 0x70, 0x48, 0x00, 0x52, 0x05, 0x6b, 0x65, 0x79, 0x55, 0x70, 0x42, 0x0c, 0x0a, 0x0a,
|
||||
0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x42, 0x16, 0x5a, 0x14, 0x72, 0x65,
|
||||
0x6c, 0x61, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
})
|
||||
|
||||
var (
|
||||
file_types_proto_rawDescOnce sync.Once
|
||||
file_types_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_types_proto_rawDescGZIP() []byte {
|
||||
file_types_proto_rawDescOnce.Do(func() {
|
||||
file_types_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_proto_rawDesc), len(file_types_proto_rawDesc)))
|
||||
})
|
||||
return file_types_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_types_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_types_proto_goTypes = []any{
|
||||
(*ProtoMouseMove)(nil), // 0: proto.ProtoMouseMove
|
||||
(*ProtoMouseMoveAbs)(nil), // 1: proto.ProtoMouseMoveAbs
|
||||
(*ProtoMouseWheel)(nil), // 2: proto.ProtoMouseWheel
|
||||
(*ProtoMouseKeyDown)(nil), // 3: proto.ProtoMouseKeyDown
|
||||
(*ProtoMouseKeyUp)(nil), // 4: proto.ProtoMouseKeyUp
|
||||
(*ProtoKeyDown)(nil), // 5: proto.ProtoKeyDown
|
||||
(*ProtoKeyUp)(nil), // 6: proto.ProtoKeyUp
|
||||
(*ProtoInput)(nil), // 7: proto.ProtoInput
|
||||
}
|
||||
var file_types_proto_depIdxs = []int32{
|
||||
0, // 0: proto.ProtoInput.mouse_move:type_name -> proto.ProtoMouseMove
|
||||
1, // 1: proto.ProtoInput.mouse_move_abs:type_name -> proto.ProtoMouseMoveAbs
|
||||
2, // 2: proto.ProtoInput.mouse_wheel:type_name -> proto.ProtoMouseWheel
|
||||
3, // 3: proto.ProtoInput.mouse_key_down:type_name -> proto.ProtoMouseKeyDown
|
||||
4, // 4: proto.ProtoInput.mouse_key_up:type_name -> proto.ProtoMouseKeyUp
|
||||
5, // 5: proto.ProtoInput.key_down:type_name -> proto.ProtoKeyDown
|
||||
6, // 6: proto.ProtoInput.key_up:type_name -> proto.ProtoKeyUp
|
||||
7, // [7:7] is the sub-list for method output_type
|
||||
7, // [7:7] is the sub-list for method input_type
|
||||
7, // [7:7] is the sub-list for extension type_name
|
||||
7, // [7:7] is the sub-list for extension extendee
|
||||
0, // [0:7] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_types_proto_init() }
|
||||
func file_types_proto_init() {
|
||||
if File_types_proto != nil {
|
||||
return
|
||||
}
|
||||
file_types_proto_msgTypes[7].OneofWrappers = []any{
|
||||
(*ProtoInput_MouseMove)(nil),
|
||||
(*ProtoInput_MouseMoveAbs)(nil),
|
||||
(*ProtoInput_MouseWheel)(nil),
|
||||
(*ProtoInput_MouseKeyDown)(nil),
|
||||
(*ProtoInput_MouseKeyUp)(nil),
|
||||
(*ProtoInput_KeyDown)(nil),
|
||||
(*ProtoInput_KeyUp)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_proto_rawDesc), len(file_types_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_types_proto_goTypes,
|
||||
DependencyIndexes: file_types_proto_depIdxs,
|
||||
MessageInfos: file_types_proto_msgTypes,
|
||||
}.Build()
|
||||
File_types_proto = out.File
|
||||
file_types_proto_goTypes = nil
|
||||
file_types_proto_depIdxs = nil
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package relay
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/gorilla/websocket"
|
||||
"log"
|
||||
"sync"
|
||||
@@ -10,22 +11,22 @@ import (
|
||||
type SafeWebSocket struct {
|
||||
*websocket.Conn
|
||||
sync.Mutex
|
||||
closeCallback func() // OnClose callback
|
||||
binaryCallbacks map[string]OnMessageCallback // MessageBase type -> callback
|
||||
closeCallback func() // OnClose callback
|
||||
callbacks map[string]OnMessageCallback // MessageBase type -> callback
|
||||
}
|
||||
|
||||
// NewSafeWebSocket creates a new SafeWebSocket from *websocket.Conn
|
||||
func NewSafeWebSocket(conn *websocket.Conn) *SafeWebSocket {
|
||||
ws := &SafeWebSocket{
|
||||
Conn: conn,
|
||||
closeCallback: nil,
|
||||
binaryCallbacks: make(map[string]OnMessageCallback),
|
||||
Conn: conn,
|
||||
closeCallback: nil,
|
||||
callbacks: make(map[string]OnMessageCallback),
|
||||
}
|
||||
|
||||
// Launch a goroutine to handle binary messages
|
||||
// Launch a goroutine to handle messages
|
||||
go func() {
|
||||
for {
|
||||
// Read binary message
|
||||
// Read message
|
||||
kind, data, err := ws.Conn.ReadMessage()
|
||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure, websocket.CloseNoStatusReceived) {
|
||||
// If unexpected close error, break
|
||||
@@ -42,22 +43,23 @@ func NewSafeWebSocket(conn *websocket.Conn) *SafeWebSocket {
|
||||
|
||||
switch kind {
|
||||
case websocket.TextMessage:
|
||||
// Ignore, we use binary messages
|
||||
continue
|
||||
case websocket.BinaryMessage:
|
||||
// Decode message
|
||||
var msg MessageBase
|
||||
if err = DecodeMessage(data, &msg); err != nil {
|
||||
log.Printf("Failed to decode binary WebSocket message, reason: %s\n", err)
|
||||
if err = json.Unmarshal(data, &msg); err != nil {
|
||||
log.Printf("Failed to decode text WebSocket message, reason: %s\n", err)
|
||||
continue
|
||||
}
|
||||
|
||||
// Handle message type callback
|
||||
if callback, ok := ws.binaryCallbacks[msg.PayloadType]; ok {
|
||||
if callback, ok := ws.callbacks[msg.PayloadType]; ok {
|
||||
callback(data)
|
||||
} // TODO: Log unknown message type?
|
||||
break
|
||||
case websocket.BinaryMessage:
|
||||
break
|
||||
default:
|
||||
log.Printf("Unknown WebSocket message type: %d\n", kind)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,18 +90,18 @@ func (ws *SafeWebSocket) SendBinary(data []byte) error {
|
||||
func (ws *SafeWebSocket) RegisterMessageCallback(msgType string, callback OnMessageCallback) {
|
||||
ws.Lock()
|
||||
defer ws.Unlock()
|
||||
if ws.binaryCallbacks == nil {
|
||||
ws.binaryCallbacks = make(map[string]OnMessageCallback)
|
||||
if ws.callbacks == nil {
|
||||
ws.callbacks = make(map[string]OnMessageCallback)
|
||||
}
|
||||
ws.binaryCallbacks[msgType] = callback
|
||||
ws.callbacks[msgType] = callback
|
||||
}
|
||||
|
||||
// UnregisterMessageCallback removes the callback for binary message of given type
|
||||
func (ws *SafeWebSocket) UnregisterMessageCallback(msgType string) {
|
||||
ws.Lock()
|
||||
defer ws.Unlock()
|
||||
if ws.binaryCallbacks != nil {
|
||||
delete(ws.binaryCallbacks, msgType)
|
||||
if ws.callbacks != nil {
|
||||
delete(ws.callbacks, msgType)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +110,7 @@ func (ws *SafeWebSocket) RegisterOnClose(callback func()) {
|
||||
ws.closeCallback = func() {
|
||||
// Clear our callbacks
|
||||
ws.Lock()
|
||||
ws.binaryCallbacks = nil
|
||||
ws.callbacks = nil
|
||||
ws.Unlock()
|
||||
// Call the callback
|
||||
callback()
|
||||
|
||||
Reference in New Issue
Block a user