File tree 2 files changed +31
-4
lines changed
2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -69,14 +69,22 @@ func (d *dummyMonitor) Hello(userAgent string, protocol int) error {
69
69
return nil
70
70
}
71
71
72
- //TODO implement
73
72
func (d * dummyMonitor ) Describe () (* monitor.PortDescriptor , error ) {
74
73
return settings , nil
75
74
}
76
75
77
- //TODO implement
78
76
func (d * dummyMonitor ) Configure (parameterName string , value string ) error {
79
- return nil
77
+ if settings .ConfigurationParameter [parameterName ] == nil {
78
+ return fmt .Errorf ("could not find parameter named %s" , parameterName )
79
+ }
80
+ values := settings .ConfigurationParameter [parameterName ].Values
81
+ for _ , i := range values {
82
+ if i == value {
83
+ settings .ConfigurationParameter [parameterName ].Selected = value
84
+ return nil
85
+ }
86
+ }
87
+ return fmt .Errorf ("invalid value for parameter %s: %s" , parameterName , value )
80
88
}
81
89
82
90
//TODO implement
Original file line number Diff line number Diff line change @@ -186,7 +186,26 @@ func (d *Server) describe() {
186
186
}
187
187
188
188
func (d * Server ) configure (cmd string ) {
189
-
189
+ if ! d .initialized {
190
+ d .outputChan <- messageError ("configure" , "Monitor not STARTed" )
191
+ return
192
+ }
193
+ re := regexp .MustCompile (`^(\w+) (\w+)$` )
194
+ matches := re .FindStringSubmatch (cmd )
195
+ if len (matches ) != 3 {
196
+ d .outputChan <- messageError ("configure" , "Invalid CONFIGURE command" )
197
+ return
198
+ }
199
+ parameterName := matches [1 ]
200
+ value := matches [2 ]
201
+ if err := d .impl .Configure (parameterName , value ); err != nil {
202
+ d .outputChan <- messageError ("configure" , err .Error ())
203
+ return
204
+ }
205
+ d .outputChan <- & message {
206
+ EventType : "configure" ,
207
+ Message : "OK" ,
208
+ }
190
209
}
191
210
192
211
func (d * Server ) open (cmd string ) {
You can’t perform that action at this time.
0 commit comments