コード例 #1
0
ファイル: OTcpServer.cs プロジェクト: pavl0v/Ogam3
 public ReClient(Transfering transfering, Evaluator evaluator, QueryInterface queryInterface)
 {
     Transfering = transfering;
     Evaluator   = evaluator;
     Transfering.ConnectionError += OnConnectionError;
     _queryInterface              = queryInterface;
 }
コード例 #2
0
ファイル: OTcpClient.cs プロジェクト: sharkbrainguy/Ogam3
        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();
        }
コード例 #3
0
ファイル: OPipeServer.cs プロジェクト: YogurtTheHorse/Ogam3
        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()));
            });
        }
コード例 #4
0
ファイル: OTcpServer.cs プロジェクト: sharkbrainguy/Ogam3
        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));
            });
        }
コード例 #5
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();
        }
コード例 #6
0
ファイル: OTcpServer.cs プロジェクト: sharkbrainguy/Ogam3
 public ReClient(Transfering transfering, Evaluator evaluator)
 {
     Transfering = transfering;
     Evaluator   = evaluator;
     Transfering.ConnectionError += OnConnectionError;
 }