示例#1
0
 protected internal override void OnPipeClosed(Pipe pipe)
 {
     if (m_pipe == pipe)
     {
         m_pipe = null;
     }
 }
示例#2
0
        public static void SendBind(Socket destination, Pipe pipe, bool increaseSequenceNumber)
        {
            if(increaseSequenceNumber)
                destination.IncreaseSequenceNumber();

            var command = new BindCommand(destination, pipe);
            SendCommand(command);
        }
示例#3
0
 protected internal override void OnNewPipe(Pipe pipe)
 {
     //  Pair socket can only be connected to a single peer.
     //  The socket rejects any further connection requests.
     if (m_pipe == null)
         m_pipe = pipe;
     else
         pipe.Close(false);
 }
示例#4
0
 public void Hiccuped(Pipe pipe)
 {
     if (m_options.DelayAttachOnConnect)
         pipe.Terminate(false);
     else
         // Notify derived sockets of the hiccup
         XHiccuped(pipe);
 }
示例#5
0
 /// <summary>
 /// Indicate that the given pipe is now ready for reading.
 /// Pipe calls this on it's sink in response to ProcessActivateRead.
 /// When called upon an instance of SocketBase, this simply calls XReadActivated.
 /// </summary>
 /// <param name="pipe">the pipe to indicate is ready for reading</param>
 public void ReadActivated(Pipe pipe)
 {
     XReadActivated(pipe);
 }
示例#6
0
文件: Pipe.cs 项目: vordoom/netmq
 /// <summary>
 /// <see cref="PipePair"/> uses this function to let us know about the peer pipe object.
 /// </summary>
 /// <param name="peer">The peer to be assigned.</param>
 private void SetPeer([NotNull] Pipe peer)
 {
     // Peer can be set once only.
     Debug.Assert(peer != null);
     m_peer = peer;
 }
示例#7
0
        /// <summary>
        /// The parent SessionBase class calls this when the Detach method finishes detaching.
        /// </summary>
        private void Detached()
        {
            // Transient session self-destructs after peer disconnects.
            if (!m_connect)
            {
                Terminate();
                return;
            }

            // For delayed connect situations, terminate the pipe
            // and reestablish later on
            if (m_pipe != null && m_options.DelayAttachOnConnect
                && m_addr.Protocol != Address.PgmProtocol && m_addr.Protocol != Address.EpgmProtocol)
            {
                m_pipe.Hiccup();
                m_pipe.Terminate(false);
                m_terminatingPipes.Add(m_pipe);
                m_pipe = null;
            }

            Reset();

            // Reconnect.
            if (m_options.ReconnectIvl != -1)
                StartConnecting(true);

            // For subscriber sockets we hiccup the inbound pipe, which will cause
            // the socket object to resend all the subscriptions.
            if (m_pipe != null && (m_options.SocketType == ZmqSocketType.Sub || m_options.SocketType == ZmqSocketType.Xsub))
                m_pipe.Hiccup();
        }
示例#8
0
 public void Hiccuped(Pipe pipe)
 {
     // Hiccups are always sent from session to socket, not the other
     // way round.
     throw new NotSupportedException("Must Override");
 }
示例#9
0
        /// <summary>
        /// Indicate that the given pipe is now ready for reading.
        /// Pipe calls this on it's sink in response to ProcessActivateRead.
        /// </summary>
        /// <param name="pipe">the pipe to indicate is ready for reading</param>
        public void ReadActivated(Pipe pipe)
        {
            // Skip activating if we're detaching this pipe
            if (m_pipe != pipe)
            {
                Debug.Assert(m_terminatingPipes.Contains(pipe));
                return;
            }

            if (m_engine != null)
                m_engine.ActivateOut();
            else
                m_pipe.CheckRead();
        }
示例#10
0
 /// <summary>
 /// Attach the given pipe to this session.
 /// </summary>
 /// <remarks>
 /// This is to be used once only, when creating the session.
 /// </remarks>
 public void AttachPipe([NotNull] Pipe pipe)
 {
     Debug.Assert(!IsTerminating);
     Debug.Assert(m_pipe == null);
     Debug.Assert(pipe != null);
     m_pipe = pipe;
     m_pipe.SetEventSink(this);
 }
示例#11
0
文件: ZObject.cs 项目: awb99/netmq
 /// <summary>
 /// Process the bind command with the given pipe.
 /// </summary>
 /// <param name="pipe"></param>
 /// <exception cref="NotSupportedException">Not supported on the ZObject class.</exception>
 protected virtual void ProcessBind( Pipe pipe)
 {
     throw new NotSupportedException();
 }
示例#12
0
 public Endpoint(Own own, Pipe pipe)
 {
     Own = own;
     Pipe = pipe;
 }
示例#13
0
 public void Hiccuped(Pipe pipe)
 {
     // Hiccups are always sent from session to socket, not the other
     // way round.
     throw new NotSupportedException("Must Override");
 }
示例#14
0
 /// <summary>
 /// Process the bind command with the given pipe.
 /// </summary>
 /// <param name="pipe"></param>
 /// <exception cref="NotSupportedException">Not supported on the ZObject class.</exception>
 protected virtual void ProcessBind([NotNull] Pipe pipe)
 {
     throw new NotSupportedException();
 }
示例#15
0
 protected void SendPipeTermAck([NotNull] Pipe destination)
 {
     SendCommand(new Command(destination, CommandType.PipeTermAck));
 }
示例#16
0
 protected void SendHiccup([NotNull] Pipe destination, [NotNull] object pipe)
 {
     SendCommand(new Command(destination, CommandType.Hiccup, pipe));
 }
示例#17
0
 protected void SendActivateWrite([NotNull] Pipe destination, long msgsRead)
 {
     SendCommand(new Command(destination, CommandType.ActivateWrite, msgsRead));
 }
示例#18
0
 protected void SendActivateRead([NotNull] Pipe destination)
 {
     SendCommand(new Command(destination, CommandType.ActivateRead));
 }
示例#19
0
 public static void SendActivateRead(Pipe destination)
 {
     var command = new ActivateReadCommand(destination);
     SendCommand(command);
 }
示例#20
0
文件: Socket.cs 项目: somdoron/NetMQ4
        private void AttachPipe(Pipe pipe)
        {
            //  First, register the pipe so that we can terminate it later on.
            m_pipes.Add(pipe);

            pipe.PipeClosed += PipeClosed;
            pipe.WriteActivated += WriteActivated;
            pipe.ReadActivated += ReadActivated;
            pipe.Hiccuped += Hiccuped;

            //  Let the protocol know about new pipe.
            m_protocol.OnNewPipe(pipe);

            //  If the socket is already being closed, ask any new pipes to terminate
            //  straight away.
            if (IsClosing)
            {
                RegisterCloseAcks(1);
                pipe.Close(false);
            }
        }
示例#21
0
 public static void SendActivateWrite(Pipe destination, long messagesRead)
 {
     var command = new ActivateWriteCommand(destination, messagesRead);
     SendCommand(command);
 }
示例#22
0
        /// <summary>
        /// This gets called by ProcessPipeTermAck or XTerminated to respond to the termination of the given pipe.
        /// </summary>
        /// <param name="pipe">the pipe that was terminated</param>
        public void Terminated(Pipe pipe)
        {
            // Drop the reference to the deallocated pipe.
            Debug.Assert(m_pipe == pipe || m_terminatingPipes.Contains(pipe));

            if (m_pipe == pipe)
                // If this is our current pipe, remove it
                m_pipe = null;
            else
                // Remove the pipe from the detached pipes set
                m_terminatingPipes.Remove(pipe);

            if (!IsTerminating && m_options.RawSocket)
            {
                if (m_engine != null)
                {
                    m_engine.Terminate();
                    m_engine = null;
                }
                Terminate();
            }

            // If we are waiting for pending messages to be sent, at this point
            // we are sure that there will be no more messages and we can proceed
            // with termination safely.
            if (m_pending && m_pipe == null && m_terminatingPipes.Count == 0)
                ProceedWithTerm();
        }
示例#23
0
 public static void SendClosePipe(Pipe destination)
 {
     var command = new ClosePipeCommand(destination);
     SendCommand(command);
 }
示例#24
0
        public void WriteActivated(Pipe pipe)
        {
            // Skip activating if we're detaching this pipe
            if (m_pipe != pipe)
            {
                Debug.Assert(m_terminatingPipes.Contains(pipe));
                return;
            }

            if (m_engine != null)
                m_engine.ActivateIn();
        }
示例#25
0
 public static void SendHiccup(Pipe destination, YPipe<Frame> pipe)
 {
     var command = new HiccupCommand(destination, pipe);
     SendCommand(command);
 }
示例#26
0
        /// <summary>
        /// Process the Attach-request by hooking up the pipes
        /// and plugging in the given engine.
        /// </summary>
        /// <param name="engine">the IEngine to plug in</param>
        protected override void ProcessAttach(IEngine engine)
        {
            Debug.Assert(engine != null);

            // Create the pipe if it does not exist yet.
            if (m_pipe == null && !IsTerminating)
            {
                ZObject[] parents = { this, m_socket };
                int[] highWaterMarks = { m_options.ReceiveHighWatermark, m_options.SendHighWatermark };
                int[] lowWaterMarks = { m_options.ReceiveLowWatermark, m_options.SendLowWatermark };
                bool[] delays = { m_options.DelayOnClose, m_options.DelayOnDisconnect };
                Pipe[] pipes = Pipe.PipePair(parents, highWaterMarks, lowWaterMarks, delays);

                // Plug the local end of the pipe.
                pipes[0].SetEventSink(this);

                // Remember the local end of the pipe.
                Debug.Assert(m_pipe == null);
                m_pipe = pipes[0];

                // Ask socket to plug into the remote end of the pipe.
                SendBind(m_socket, pipes[1]);
            }

            // Plug in the engine.
            Debug.Assert(m_engine == null);
            m_engine = engine;
            m_engine.Plug(m_ioThread, this);
        }
示例#27
0
文件: ZObject.cs 项目: awb99/netmq
        /// <summary>
        /// Send the Bind command
        /// </summary>
        /// <param name="destination"></param>
        /// <param name="pipe"></param>
        /// <param name="incSeqnum"></param>
        protected void SendBind( Own destination,  Pipe pipe, bool incSeqnum = true)
        {
            if (incSeqnum)
                destination.IncSeqnum();

            SendCommand(new Command(destination, CommandType.Bind, pipe));
        }
示例#28
0
文件: Pipe.cs 项目: vordoom/netmq
 /// <summary>
 /// Create a new Pipe object with the given parent, and inbound and outbound YPipes.
 /// </summary>
 /// <remarks>
 /// Constructor is private as pipe can only be created using <see cref="PipePair"/> method.
 /// </remarks>
 private Pipe(
     [NotNull] ZObject parent, [NotNull] YPipe<Msg> inboundPipe, [NotNull] YPipe<Msg> outboundPipe,
     int inHighWatermark, int outHighWatermark, int predefinedLowWatermark, bool delay)
     : base(parent)
 {
     m_parent = parent;
     m_inboundPipe = inboundPipe;
     m_outboundPipe = outboundPipe;
     m_inActive = true;
     m_outActive = true;
     m_highWatermark = outHighWatermark;
     m_lowWatermark = ComputeLowWatermark(inHighWatermark, predefinedLowWatermark);
     m_numberOfMessagesRead = 0;
     m_numberOfMessagesWritten = 0;
     m_peersMsgsRead = 0;
     m_peer = null;
     m_sink = null;
     m_state = State.Active;
     m_delay = delay;
 }
示例#29
0
文件: ZObject.cs 项目: awb99/netmq
 protected void SendActivateRead( Pipe destination)
 {
     SendCommand(new Command(destination, CommandType.ActivateRead));
 }
示例#30
0
 /// <summary>
 /// Process a Bind command by attaching the given Pipe.
 /// </summary>
 /// <param name="pipe">the Pipe to attach</param>
 protected override void ProcessBind(Pipe pipe)
 {
     AttachPipe(pipe);
 }
示例#31
0
文件: ZObject.cs 项目: awb99/netmq
 protected void SendActivateWrite( Pipe destination, long msgsRead)
 {
     SendCommand(new Command(destination, CommandType.ActivateWrite, msgsRead));
 }
示例#32
0
 /// <summary>
 /// When called upon an instance of SocketBase, this simply calls XWriteActivated.
 /// </summary>
 /// <param name="pipe">the pipe to indicate is ready for writing</param>
 public void WriteActivated(Pipe pipe)
 {
     XWriteActivated(pipe);
 }
示例#33
0
文件: ZObject.cs 项目: awb99/netmq
 protected void SendHiccup( Pipe destination,  object pipe)
 {
     SendCommand(new Command(destination, CommandType.Hiccup, pipe));
 }
示例#34
0
        /// <summary>
        /// This gets called by ProcessPipeTermAck or XTerminated to respond to the termination of the given pipe.
        /// </summary>
        /// <param name="pipe">the pipe that was terminated</param>
        public void Terminated(Pipe pipe)
        {
            // Notify the specific socket type about the pipe termination.
            XTerminated(pipe);

            // Remove pipe from inproc pipes
            var pipesToDelete = m_inprocs.Where(i => i.Value == pipe).Select(i => i.Key).ToArray();
            foreach (var addr in pipesToDelete)
            {
                m_inprocs.Remove(addr);
            }

            // Remove the pipe from the list of attached pipes and confirm its
            // termination if we are already shutting down.
            m_pipes.Remove(pipe);
            if (IsTerminating)
                UnregisterTermAck();
        }
示例#35
0
文件: ZObject.cs 项目: awb99/netmq
 protected void SendPipeTermAck( Pipe destination)
 {
     SendCommand(new Command(destination, CommandType.PipeTermAck));
 }
示例#36
0
 /// <summary>
 /// Take ownership of the given <paramref name="endpoint"/> and register it against the given <paramref name="address"/>.
 /// </summary>
 private void AddEndpoint([NotNull] string address, [NotNull] Own endpoint, Pipe pipe)
 {
     // Activate the session. Make it a child of this socket.
     LaunchChild(endpoint);
     m_endpoints[address] = new Endpoint(endpoint, pipe);
 }
示例#37
0
 /// <summary>
 /// <see cref="PipePair"/> uses this function to let us know about the peer pipe object.
 /// </summary>
 /// <param name="peer">The peer to be assigned.</param>
 private void SetPeer([NotNull] Pipe peer)
 {
     // Peer can be set once only.
     Debug.Assert(peer != null);
     m_peer = peer;
 }