Example #1
0
        private void ConnectServer()
        {
            var ns = new NetStream(ConnectTcp());

            _transfering?.Dispose();
            _transfering = new Transfering(ns, ns, BufferSize);

            _transfering.ConnectionStabilised = OnConnectionStabilised;

            _transfering.ConnectionError = ex => {
                lock (_transfering) {
                    // for single raction
                    _transfering.ConnectionError = null;

                    _sendSync.Lock();
                    Console.WriteLine($"Connection ERROR {ex.Message}");
                    OnConnectionError(ex);

                    _connSync.Pulse();
                }
            };

            _transfering.StartReceiver(data => OTcpServer.DataHandler(_evaluator, data));

            _sendSync.Unlock();
        }
Example #2
0
        private void ClientConnection(PipeServer pserver)
        {
            //var client = (TcpClient)o;
            //var endpoint = (IPEndPoint)client.Client.RemoteEndPoint;
            //Log?.Invoke($"(client-connected \"{endpoint.Address}:{endpoint.Port}\")");

            //var ns = new NetStream(client);

            var server = new Transfering(pserver.SendStream, pserver.ReceiveStream, BufferSize);

            server.StartReceiver(data => {
                //SetContextObj(ContextTcpClientId, client); // TODO single set
                SetContextObj(ReClientId, new OTcpServer.ReClient(server, Evaluator, _queryInterface)); // TODO single set

                return(DataHandler(Evaluator, data, _queryInterface.GetSymbolTable()));
            });
        }
Example #3
0
        private void ClientConnection(object o)
        {
            var client   = (TcpClient)o;
            var endpoint = (IPEndPoint)client.Client.RemoteEndPoint;

            Log?.Invoke($"(client-connected \"{endpoint.Address}:{endpoint.Port}\")");

            var ns = new NetStream(client);

            var server = new Transfering(ns, ns, BufferSize);

            server.StartReceiver(data => {
                SetContextObj(ContextTcpClientId, client);                  // TODO single set
                SetContextObj(ReClientId, new ReClient(server, Evaluator)); // TODO single set

                return(DataHandler(Evaluator, data));
            });
        }
Example #4
0
        private void ConnectServer()
        {
            var ns = new NetStream(ConnectTcp());

            _transfering?.Dispose();
            _transfering = new Transfering(ns, ns, BufferSize);

            var isReconnected = false;

            _transfering.ConnectionStabilised = OnConnectionStabilised + new Action(() => {
                if (isReconnected)
                {
                    _symbolTable = new SymbolTable(_serverQueryInterfaceProxy.GetIndexedSymbols());
                }
                else
                {
                    isReconnected = true;
                }
            });

            _transfering.ConnectionError = ex => {
                lock (_transfering) {
                    // for single raction
                    _transfering.ConnectionError = null;

                    _sendSync.Lock();
                    Console.WriteLine($"Connection ERROR {ex.Message}");
                    OnConnectionError(ex);

                    _connSync.Pulse();
                }
            };

            _transfering.StartReceiver(data => OTcpServer.DataHandler(_evaluator, data, _symbolTable));

            _sendSync.Unlock();
        }