77using Buttplug . Core ;
88using Buttplug . Core . Messages ;
99using JetBrains . Annotations ;
10- using static Buttplug . Client . DeviceEventArgs ;
11- using WebSocket4Net ;
1210using SuperSocket . ClientEngine ;
11+ using WebSocket4Net ;
12+ using static Buttplug . Client . DeviceEventArgs ;
1313
1414namespace Buttplug . Client
1515{
@@ -305,7 +305,7 @@ private async void onPingTimer(object state)
305305 {
306306 try
307307 {
308- var msg = await SendMessage ( new Ping ( nextMsgId ) ) ;
308+ var msg = await SendMessage ( new Ping ( ) ) ;
309309 if ( msg is Error )
310310 {
311311 _owningDispatcher . Send ( _ =>
@@ -326,7 +326,7 @@ private async void onPingTimer(object state)
326326
327327 public async Task RequestDeviceList ( )
328328 {
329- var resp = await SendMessage ( new RequestDeviceList ( nextMsgId ) ) ;
329+ var resp = await SendMessage ( new RequestDeviceList ( ) ) ;
330330 if ( ! ( resp is DeviceList ) || ( resp as DeviceList ) . Devices == null )
331331 {
332332 if ( resp is Error )
@@ -365,17 +365,17 @@ public ButtplugClientDevice[] getDevices()
365365
366366 public async Task < bool > StartScanning ( )
367367 {
368- return await SendMessageExpectOk ( new StartScanning ( nextMsgId ) ) ;
368+ return await SendMessageExpectOk ( new StartScanning ( ) ) ;
369369 }
370370
371371 public async Task < bool > StopScanning ( )
372372 {
373- return await SendMessageExpectOk ( new StopScanning ( nextMsgId ) ) ;
373+ return await SendMessageExpectOk ( new StopScanning ( ) ) ;
374374 }
375375
376376 public async Task < bool > RequestLog ( string aLogLevel )
377377 {
378- return await this . SendMessageExpectOk ( new RequestLog ( aLogLevel , nextMsgId ) ) ;
378+ return await this . SendMessageExpectOk ( new RequestLog ( aLogLevel ) ) ;
379379 }
380380
381381 public async Task < ButtplugMessage > SendDeviceMessage ( ButtplugClientDevice aDevice , ButtplugDeviceMessage aDeviceMsg )
@@ -403,6 +403,9 @@ protected async Task<bool> SendMessageExpectOk(ButtplugMessage aMsg)
403403
404404 protected async Task < ButtplugMessage > SendMessage ( ButtplugMessage aMsg )
405405 {
406+ // The client always increments the IDs on outgoing messages
407+ aMsg . Id = nextMsgId ;
408+
406409 var promise = new TaskCompletionSource < ButtplugMessage > ( ) ;
407410 _waitingMsgs . TryAdd ( aMsg . Id , promise ) ;
408411
0 commit comments