static void Main(string[] args) { while (true) { Thread.Sleep(5000); TcpClient client = new TcpClient("localhost", 6000); NetworkStream stream = client.GetStream(); try { while (true) { Package package = null; int a = Convert.ToInt32(Console.ReadLine()); switch (a) { case 2: { int b = Convert.ToInt32(Console.ReadLine()); string s = Console.ReadLine(); package = new ClientLoginPackage((byte)b, s); break; } case 4: { package = new ClientTemperaturePackage(78.6f); break; } case 5: { int b = Convert.ToInt32(Console.ReadLine()); package = new ClientSpeedPackage(b, 25.0f); break; } case 6: { package = new ClientStopPackage(45.8f); break; } case 9: { package = new ClientClosePackage(78.9f); break; } case 11: { package = new ClientTargetTemperaturePackage(34.6f); break; } default: break; } byte[] bt = PackageHelper.GetByte(package); stream.Write(bt, 0, bt.Length); if (package.Cat == 2) { Console.WriteLine(GetRequest(stream).ToString()); } } } catch (Exception e) { Console.Write(e); } finally { if (stream != null) { stream.Dispose(); } if (client != null) { client.Close(); } } } }
public static void sendStopSpeedRequest(float tp) { byte[] buffer = PackageHelper.GetByte(new ClientStopPackage(tp)); Client.sendPackage(buffer); }
public static void sendSpeedRequest(int speed, float tp) { byte[] buffer = PackageHelper.GetByte(new ClientSpeedPackage(speed, tp)); Client.sendPackage(buffer); }
public static void sendTpChange(float tp) { byte[] buffer = PackageHelper.GetByte(new ClientTargetTemperaturePackage(tp)); Client.sendPackage(buffer); }
public static void sendClientCloseRequest(float tp) { byte[] buffer = PackageHelper.GetByte(new ClientClosePackage(tp)); Client.sendPackage(buffer); }
public static void sendLoginRequest(int roomNumber, String id) { byte[] buffer = PackageHelper.GetByte(new ClientLoginPackage((byte)roomNumber, id)); Client.sendPackage(buffer); }