@@ -5,6 +5,7 @@ use thiserror::Error;
5
5
use validator:: Validate ;
6
6
7
7
use crate :: {
8
+ component:: ComponentName ,
8
9
global:: { Global , InputMessage , InputMessageData , InputSourceHandle } ,
9
10
image:: { RawImage , RawImageError } ,
10
11
} ;
@@ -47,12 +48,14 @@ impl ClientConnection {
47
48
match request. command {
48
49
HyperionCommand :: ClearAll => {
49
50
// Update state
50
- self . source . send ( InputMessageData :: ClearAll ) ?;
51
+ self . source
52
+ . send ( ComponentName :: All , InputMessageData :: ClearAll ) ?;
51
53
}
52
54
53
55
HyperionCommand :: Clear ( message:: Clear { priority } ) => {
54
56
// Update state
55
- self . source . send ( InputMessageData :: Clear { priority } ) ?;
57
+ self . source
58
+ . send ( ComponentName :: All , InputMessageData :: Clear { priority } ) ?;
56
59
}
57
60
58
61
HyperionCommand :: Color ( message:: Color {
@@ -64,11 +67,14 @@ impl ClientConnection {
64
67
// TODO: Handle origin field
65
68
66
69
// Update state
67
- self . source . send ( InputMessageData :: SolidColor {
68
- priority,
69
- duration : duration. map ( |ms| chrono:: Duration :: milliseconds ( ms as _ ) ) ,
70
- color,
71
- } ) ?;
70
+ self . source . send (
71
+ ComponentName :: Color ,
72
+ InputMessageData :: SolidColor {
73
+ priority,
74
+ duration : duration. map ( |ms| chrono:: Duration :: milliseconds ( ms as _ ) ) ,
75
+ color,
76
+ } ,
77
+ ) ?;
72
78
}
73
79
74
80
HyperionCommand :: Image ( message:: Image {
@@ -86,44 +92,55 @@ impl ClientConnection {
86
92
87
93
let raw_image = RawImage :: try_from ( ( imagedata, imagewidth, imageheight) ) ?;
88
94
89
- self . source . send ( InputMessageData :: Image {
90
- priority,
91
- duration : duration. map ( |ms| chrono:: Duration :: milliseconds ( ms as _ ) ) ,
92
- image : Arc :: new ( raw_image) ,
93
- } ) ?;
95
+ self . source . send (
96
+ ComponentName :: Image ,
97
+ InputMessageData :: Image {
98
+ priority,
99
+ duration : duration. map ( |ms| chrono:: Duration :: milliseconds ( ms as _ ) ) ,
100
+ image : Arc :: new ( raw_image) ,
101
+ } ,
102
+ ) ?;
94
103
}
95
104
96
105
HyperionCommand :: ServerInfo ( message:: ServerInfoRequest { subscribe : _ } ) => {
97
106
// TODO: Handle subscribe field
98
107
99
108
// Request priority information
100
109
let ( sender, receiver) = tokio:: sync:: oneshot:: channel ( ) ;
101
- self . source . send ( InputMessageData :: PrioritiesRequest {
102
- response : Arc :: new ( std:: sync:: Mutex :: new ( Some ( sender) ) ) ,
103
- } ) ?;
110
+ self . source . send (
111
+ ComponentName :: All ,
112
+ InputMessageData :: PrioritiesRequest {
113
+ response : Arc :: new ( std:: sync:: Mutex :: new ( Some ( sender) ) ) ,
114
+ } ,
115
+ ) ?;
104
116
105
117
// Receive priority information
106
- let priorities = receiver
107
- . await ?
108
- . into_iter ( )
109
- . map ( message:: PriorityInfo :: from)
110
- . collect ( ) ;
118
+ let priorities = receiver. await ?. into_iter ( ) . collect ( ) ;
111
119
112
120
// Just answer the serverinfo request, no need to update state
113
- return Ok ( Some ( HyperionResponse :: server_info (
114
- request. tan ,
115
- vec ! [ ] ,
116
- priorities,
121
+
122
+ return Ok ( Some (
117
123
global
118
124
. read_config ( |config| {
119
- config
125
+ let instances = config
120
126
. instances
121
127
. iter ( )
122
128
. map ( |instance_config| ( & instance_config. 1 . instance ) . into ( ) )
123
- . collect ( )
129
+ . collect ( ) ;
130
+
131
+ HyperionResponse :: server_info (
132
+ request. tan ,
133
+ // TODO: Priorities only for current instance
134
+ priorities,
135
+ // TODO: Fill adjustments
136
+ vec ! [ ] ,
137
+ // TODO: Fill effects
138
+ vec ! [ ] ,
139
+ instances,
140
+ )
124
141
} )
125
142
. await ,
126
- ) ) ) ;
143
+ ) ) ;
127
144
}
128
145
129
146
HyperionCommand :: Authorize ( message:: Authorize { subcommand, .. } ) => match subcommand {
0 commit comments