From 2149494a10c4f9f2e0acdc560371e7255f8aa621 Mon Sep 17 00:00:00 2001 From: elianiva Date: Mon, 7 Mar 2022 18:59:59 +0700 Subject: [PATCH 1/4] feat: add events proto --- proto/Spectator.Protos/enums.proto | 8 +++++ proto/Spectator.Protos/events.proto | 54 +++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 proto/Spectator.Protos/events.proto diff --git a/proto/Spectator.Protos/enums.proto b/proto/Spectator.Protos/enums.proto index a1593b43..dd5b596d 100644 --- a/proto/Spectator.Protos/enums.proto +++ b/proto/Spectator.Protos/enums.proto @@ -18,3 +18,11 @@ enum Language { JAVA = 5; PYTHON = 6; } + +enum Direction { + STOP = 0; + UP = 1; + LEFT = 2; + RIGHT = 3; + DOWN = 4; +} \ No newline at end of file diff --git a/proto/Spectator.Protos/events.proto b/proto/Spectator.Protos/events.proto new file mode 100644 index 00000000..7a9b039b --- /dev/null +++ b/proto/Spectator.Protos/events.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; + +option csharp_namespace = "Spectator.Protos.Events"; + +package events; + +import "enums.proto"; + +service EventsService { + rpc MouseClick (MouseClickRequest) returns (EmptyReply); + rpc MouseMove (MouseMoveRequest) returns (EmptyReply); + rpc MouseScroll (MouseScrollRequest) returns (EmptyReply); + rpc Keystroke (KeystrokeRequest) returns (EmptyReply); +} + +message MouseClickRequest { + string access_token = 1; + int32 question_number = 2; + bool right_click = 3; + bool left_click = 4; + bool middle_click = 5; + string time = 6; +} + +message MouseMoveRequest { + string access_token = 1; + int32 question_number = 2; + enums.Direction direction = 3; + int32 x_position = 4; + int32 y_position = 5; + int32 window_width = 6; + int32 window_height = 7; + string time = 8; +} + +message MouseScrollRequest { + string access_token = 1; + string time = 2; +} + +message KeystrokeRequest { + string access_token = 1; + int32 question_number = 2; + string key_char = 3; + bool shift = 4; + bool alt = 5; + bool control = 6; + bool meta = 7; + bool unrelated_key = 8; + string time = 9; +} + +message EmptyReply { +} \ No newline at end of file From ced75cbe544e588392b80872fae46c96f22d661a Mon Sep 17 00:00:00 2001 From: elianiva Date: Mon, 7 Mar 2022 20:02:43 +0700 Subject: [PATCH 2/4] refactor: reply with non-empty response --- proto/Spectator.Protos/events.proto | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/proto/Spectator.Protos/events.proto b/proto/Spectator.Protos/events.proto index 7a9b039b..22df99f8 100644 --- a/proto/Spectator.Protos/events.proto +++ b/proto/Spectator.Protos/events.proto @@ -7,10 +7,10 @@ package events; import "enums.proto"; service EventsService { - rpc MouseClick (MouseClickRequest) returns (EmptyReply); - rpc MouseMove (MouseMoveRequest) returns (EmptyReply); - rpc MouseScroll (MouseScrollRequest) returns (EmptyReply); - rpc Keystroke (KeystrokeRequest) returns (EmptyReply); + rpc MouseClick (MouseClickRequest) returns (EventReply); + rpc MouseMove (MouseMoveRequest) returns (EventReply); + rpc MouseScroll (MouseScrollRequest) returns (EventReply); + rpc Keystroke (KeystrokeRequest) returns (EventReply); } message MouseClickRequest { @@ -50,5 +50,6 @@ message KeystrokeRequest { string time = 9; } -message EmptyReply { +message EventReply { + string message = 1; } \ No newline at end of file From 6c17aca59311d49a27ef01820294d9f1046f6d31 Mon Sep 17 00:00:00 2001 From: elianiva Date: Thu, 10 Mar 2022 20:24:56 +0700 Subject: [PATCH 3/4] refactor(proto): use int64 for timestamp --- proto/Spectator.Protos/events.proto | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proto/Spectator.Protos/events.proto b/proto/Spectator.Protos/events.proto index 22df99f8..58e84ee5 100644 --- a/proto/Spectator.Protos/events.proto +++ b/proto/Spectator.Protos/events.proto @@ -19,7 +19,7 @@ message MouseClickRequest { bool right_click = 3; bool left_click = 4; bool middle_click = 5; - string time = 6; + int64 time = 6; } message MouseMoveRequest { @@ -30,12 +30,12 @@ message MouseMoveRequest { int32 y_position = 5; int32 window_width = 6; int32 window_height = 7; - string time = 8; + int64 time = 8; } message MouseScrollRequest { string access_token = 1; - string time = 2; + int64 time = 2; } message KeystrokeRequest { @@ -47,7 +47,7 @@ message KeystrokeRequest { bool control = 6; bool meta = 7; bool unrelated_key = 8; - string time = 9; + int64 time = 9; } message EventReply { From e21e9c9e5cc2521eaf36afc675dbf104c616632b Mon Sep 17 00:00:00 2001 From: elianiva Date: Thu, 10 Mar 2022 20:28:37 +0700 Subject: [PATCH 4/4] refactor(proto): use enum for MouseClick --- proto/Spectator.Protos/enums.proto | 6 ++++++ proto/Spectator.Protos/events.proto | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/proto/Spectator.Protos/enums.proto b/proto/Spectator.Protos/enums.proto index dd5b596d..c1dfc468 100644 --- a/proto/Spectator.Protos/enums.proto +++ b/proto/Spectator.Protos/enums.proto @@ -25,4 +25,10 @@ enum Direction { LEFT = 2; RIGHT = 3; DOWN = 4; +} + +enum MouseButton { + LEFT_BUTTON = 0; + RIGHT_BUTTON = 1; + MIDDLE_BUTTON = 2; } \ No newline at end of file diff --git a/proto/Spectator.Protos/events.proto b/proto/Spectator.Protos/events.proto index 58e84ee5..f786c36c 100644 --- a/proto/Spectator.Protos/events.proto +++ b/proto/Spectator.Protos/events.proto @@ -16,10 +16,8 @@ service EventsService { message MouseClickRequest { string access_token = 1; int32 question_number = 2; - bool right_click = 3; - bool left_click = 4; - bool middle_click = 5; - int64 time = 6; + enums.MouseButton button = 3; + int64 time = 4; } message MouseMoveRequest {