81 lines
3.3 KiB
C#
81 lines
3.3 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.Text;
|
|
|
|
namespace VideoReader
|
|
{
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
Console.WriteLine("VideoReader Global Edition v1.0");
|
|
Console.WriteLine("===================================");
|
|
Console.WriteLine();
|
|
|
|
// Инициализируем детальное логгирование
|
|
DetailedLogger.Initialize();
|
|
DetailedLogger.LogInfo("Application started");
|
|
|
|
try
|
|
{
|
|
// Загружаем конфигурацию
|
|
var config = ServerConfig.LoadConfig();
|
|
DetailedLogger.LogInfo($"Loaded server configuration: {config.ServerAddress}:{config.Port}");
|
|
DetailedLogger.LogInfo($"Channel: {config.Channel}");
|
|
DetailedLogger.LogInfo($"Server Type: {config.ServerType}");
|
|
Console.WriteLine($"Loaded server configuration: {config.ServerAddress}:{config.Port}");
|
|
Console.WriteLine($"Channel: {config.Channel}");
|
|
Console.WriteLine($"Server Type: {config.ServerType}");
|
|
Console.WriteLine();
|
|
|
|
// Создаем подключение (без GUI)
|
|
var socket = new InOutSocket();
|
|
socket.Connect();
|
|
|
|
Console.WriteLine();
|
|
Console.WriteLine("Application running in console mode.");
|
|
Console.WriteLine("Commands:");
|
|
Console.WriteLine(" 's' - Show statistics");
|
|
Console.WriteLine(" 'q' - Quit");
|
|
Console.WriteLine(" 'd' - Send test data");
|
|
Console.WriteLine("Press any key to exit...");
|
|
|
|
// Интерактивный режим
|
|
while (true)
|
|
{
|
|
var key = Console.ReadKey(true);
|
|
|
|
if (key.KeyChar == 'q' || key.KeyChar == 'Q')
|
|
{
|
|
break;
|
|
}
|
|
else if (key.KeyChar == 's' || key.KeyChar == 'S')
|
|
{
|
|
Console.WriteLine($"Statistics: In={socket.bitratein} bytes, Out={socket.bitrateout} bytes");
|
|
DetailedLogger.LogInfo($"User requested statistics: In={socket.bitratein}, Out={socket.bitrateout}");
|
|
}
|
|
else if (key.KeyChar == 'd' || key.KeyChar == 'D')
|
|
{
|
|
var testData = Encoding.UTF8.GetBytes($"TEST_DATA_{DateTime.Now:HHmmss}");
|
|
socket.QueueDataForSending(testData);
|
|
Console.WriteLine("Test data queued for sending");
|
|
}
|
|
}
|
|
|
|
socket.Disconnect();
|
|
DetailedLogger.LogStatistics();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Error: {ex.Message}");
|
|
DetailedLogger.LogError($"Application error: {ex.Message}", ex);
|
|
Console.WriteLine("Press any key to exit...");
|
|
Console.ReadKey();
|
|
}
|
|
finally
|
|
{
|
|
DetailedLogger.LogInfo("Application shutdown");
|
|
}
|
|
}
|
|
}
|
|
} |