public static void SendWithErrorAnswer(IBasePacket data) { Protocol.SendTcp(Server, data); while (true) { var packet = Protocol.ReceiveTcp(Server); switch (packet) { case PingPacket: Protocol.SendTcp(Server, new PingPacket()); continue; case ErrorPacket error: throw new Exception(error.Error.ToString()); break; } if (packet is Ok) { return; } throw new Exception("Unexpected command received"); } }
public static IBasePacket Receive() { while (true) { var command = Protocol.ReceiveTcp(Server); if (command is PingPacket) { Protocol.SendTcp(Server, new PingPacket()); continue; } return(command); } }
public static IBasePacket SendWithResult(IBasePacket data) { Protocol.SendTcp(Server, data); while (true) { var result = Protocol.ReceiveTcp(Server); if (result is PingPacket) { Protocol.SendTcp(Server, new PingPacket()); continue; } return(result); } }
public static void Send(IBasePacket data) { Protocol.SendTcp(Server, data); }