Ejemplo n.º 1
0
        private void AcceptCallback(Stream stream)
        {
            var session = new DtpNodeSession(this, stream, NodeRole.Server);

            m_sessions.TryAdd(session);
            OnClientConnected(new ClientConnectedEventArgs(session));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 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);
            }
        }