server can set resistance
This commit is contained in:
@@ -16,6 +16,7 @@ namespace Client
|
||||
private int totalBufferReceived = 0;
|
||||
private EngineConnection engineConnection;
|
||||
private bool sessionRunning = false;
|
||||
private IHandler handler = null;
|
||||
|
||||
|
||||
public Client() : this("localhost", 5555)
|
||||
@@ -102,6 +103,16 @@ namespace Client
|
||||
byte[] stopSession = DataParser.getStopSessionJson();
|
||||
stream.BeginWrite(stopSession, 0, stopSession.Length, new AsyncCallback(OnWrite), null);
|
||||
break;
|
||||
case DataParser.SET_RESISTANCE:
|
||||
if (this.handler == null)
|
||||
{
|
||||
Console.WriteLine("handler is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.handler.setResistance(DataParser.getResistanceFromJson(payloadbytes));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine($"Received json with identifier {identifier}:\n{Encoding.ASCII.GetString(payloadbytes)}");
|
||||
break;
|
||||
@@ -174,5 +185,10 @@ namespace Client
|
||||
initEngine();
|
||||
this.stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWrite), null);
|
||||
}
|
||||
|
||||
public void setHandler(IHandler handler)
|
||||
{
|
||||
this.handler = handler;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using Hardware;
|
||||
using Hardware.Simulators;
|
||||
using RH_Engine;
|
||||
|
||||
namespace Client
|
||||
{
|
||||
@@ -20,13 +19,18 @@ namespace Client
|
||||
{
|
||||
|
||||
}
|
||||
//BLEHandler bLEHandler = new BLEHandler(client);
|
||||
BLEHandler bLEHandler = new BLEHandler(client);
|
||||
|
||||
//bLEHandler.Connect();
|
||||
bLEHandler.Connect();
|
||||
|
||||
BikeSimulator bikeSimulator = new BikeSimulator(client);
|
||||
client.setHandler(bLEHandler);
|
||||
|
||||
bikeSimulator.StartSimulation();
|
||||
|
||||
//BikeSimulator bikeSimulator = new BikeSimulator(client);
|
||||
|
||||
//bikeSimulator.StartSimulation();
|
||||
|
||||
//client.setHandler(bikeSimulator);
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user