Esempio n. 1
0
        public ChatForm()
        {
            InitializeComponent();
            var parametrs = new Parametrs("config.ini");

            parametrs.LoadParametrs();

            var transport = new LiteNetLibTransport(parametrs.MaxConnection, parametrs.KeyConnection);
            var protocol  = new TransportUdpProtocol(transport, parametrs.MaxMessageSize, new BinarySerializer());
            var network   = new ProtocolUdpNetwork(protocol, new RealNow(), parametrs.Timeout);

            _chatClient              = new ChatClient(transport, network, parametrs.MaxMessageLength);
            _chatClient.Message     += ChatClientOnMessage;
            _chatClient.ChangeStage += ChatClientOnChangeStage;
            _currentStage            = ClientStage.Disconnected;
        }
Esempio n. 2
0
        static void Main()
        {
            var parametrs = new Parametrs("config.ini");

            parametrs.LoadParametrs();
            var transport = new LiteNetLibTransport(parametrs.MaxConnection, parametrs.KeyConnection);
            var protocol  = new TransportUdpProtocol(transport, parametrs.MaxMessageSize, new BinarySerializer());
            var network   = new ProtocolUdpNetwork(protocol, new RealNow(), parametrs.Timeout);

            _server         = new ChatServer(network, parametrs.MaxMessageLength);
            _timer          = new Timer(100);
            _timer.Elapsed += OnTimerElapsed;
            network.Start(parametrs.Port);
            _timer.Start();

            Console.ReadKey();
        }