private void AcceptCallback(Stream stream)
        {
            var session = new DtpNodeSession(this, stream, NodeRole.Server);

            m_sessions.TryAdd(session);
            OnClientConnected(new ClientConnectedEventArgs(session));
        }
        public IDSPExSession Connect(int port)
        {
            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            socket.Connect(new IPEndPoint(IPAddress.Loopback, port));

            var session = new DtpNodeSession(this, new NetworkStream(socket), NodeRole.Client);

            m_sessions.TryAdd(session);

            return(session);
        }
        /// <summary>
        /// Connect to another DSPEx node
        /// </summary>
        /// <param name="pipeName">
        /// If null, connects to the default DSPEx pipe ("dargon" aka dargon daemon)
        /// </param>
        /// <returns></returns>
        public IDSPExSession Connect(string pipeName)
        {
            var connection = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut, PipeOptions.Asynchronous | PipeOptions.WriteThrough);

            connection.Connect();

            var session = new DtpNodeSession(this, connection, NodeRole.Client);

            m_sessions.TryAdd(session);

            return(session);
        }
示例#4
0
 public DtpNodeSessionFrameProcessor(
     DtpNode node,
     DtpNodeSession session,
     Action <DtpNodeSessionFrameProcessor, byte[]> onFrameProcessed)
 {
     m_node             = node;
     m_session          = session;
     m_onFrameProcessed = onFrameProcessed;
     m_thread           = new Thread(ThreadStart)
     {
         IsBackground = true
     };
     m_thread.Start();
 }
示例#5
0
        private void ServerThreadStart(CountdownEvent signalledOnWaitingForConnection)
        {
            while (m_isAlive)
            {
                var pipeHandle = LowIntegrityPipeFactory.CreateLowIntegrityNamedPipe(m_defaultPipeName);
                var connection = new NamedPipeServerStream(PipeDirection.InOut, true, false, pipeHandle);
                if (signalledOnWaitingForConnection != null)
                {
                    signalledOnWaitingForConnection.Signal();
                    signalledOnWaitingForConnection = null;
                }
                connection.WaitForConnection();
                Logger.L(LoggerLevel.Info, "DSPEx Node got connection");

                var session = new DtpNodeSession(this, connection, DSPExNodeRole.Server);
                m_sessions.TryAdd(session);
            }
        }