Exemple #1
0
        //  Create a socket of a specified type.
        public static SocketBase Create(ZmqSocketType type, Ctx parent,
                                        int tid, int sid)
        {
            SocketBase s;

            switch (type)
            {
            case ZmqSocketType.Pair:
                s = new Pair(parent, tid, sid);
                break;

            case ZmqSocketType.Pub:
                s = new Pub(parent, tid, sid);
                break;

            case ZmqSocketType.Sub:
                s = new Sub(parent, tid, sid);
                break;

            case ZmqSocketType.Req:
                s = new Req(parent, tid, sid);
                break;

            case ZmqSocketType.Rep:
                s = new Rep(parent, tid, sid);
                break;

            case ZmqSocketType.Dealer:
                s = new Dealer(parent, tid, sid);
                break;

            case ZmqSocketType.Router:
                s = new Router(parent, tid, sid);
                break;

            case ZmqSocketType.Pull:
                s = new Pull(parent, tid, sid);
                break;

            case ZmqSocketType.Push:
                s = new Push(parent, tid, sid);
                break;

            case ZmqSocketType.Xpub:
                s = new XPub(parent, tid, sid);
                break;

            case ZmqSocketType.Xsub:
                s = new XSub(parent, tid, sid);
                break;

            case ZmqSocketType.Stream:
                s = new Stream(parent, tid, sid);
                break;

            default:
                throw InvalidException.Create("type=" + type);
            }
            return(s);
        }
Exemple #2
0
        static XPub()
        {
            s_markAsMatching = (pipe, data, arg) =>
            {
                XPub self = (XPub)arg;
                self.m_dist.Match(pipe);
            };

            s_SendUnsubscription = (pipe, data, arg) =>
            {
                XPub self = (XPub)arg;

                if (self.m_options.SocketType != ZmqSocketType.Pub)
                {
                    //  Place the unsubscription to the queue of pending (un)sunscriptions
                    //  to be retrived by the user later on.
                    Blob unsub = new Blob(data.Length + 1);
                    unsub.Put(0, (byte)0);
                    unsub.Put(1, data);
                    self.m_pending.Enqueue(unsub);
                }
            };
        }
Exemple #3
0
        //  Create a socket of a specified type.
        public static SocketBase Create(ZmqSocketType type, Ctx parent,
                                                                                                                                        int tid, int sid)
        {
            SocketBase s;
            switch (type)
            {

                case ZmqSocketType.Pair:
                    s = new Pair(parent, tid, sid);
                    break;
                case ZmqSocketType.Pub:
                    s = new Pub(parent, tid, sid);
                    break;
                case ZmqSocketType.Sub:
                    s = new Sub(parent, tid, sid);
                    break;
                case ZmqSocketType.Req:
                    s = new Req(parent, tid, sid);
                    break;
                case ZmqSocketType.Rep:
                    s = new Rep(parent, tid, sid);
                    break;
                case ZmqSocketType.Dealer:
                    s = new Dealer(parent, tid, sid);
                    break;
                case ZmqSocketType.Router:
                    s = new Router(parent, tid, sid);
                    break;
                case ZmqSocketType.Pull:
                    s = new Pull(parent, tid, sid);
                    break;
                case ZmqSocketType.Push:
                    s = new Push(parent, tid, sid);
                    break;

                case ZmqSocketType.Xpub:
                    s = new XPub(parent, tid, sid);
                    break;

                case ZmqSocketType.Xsub:
                    s = new XSub(parent, tid, sid);
                    break;
                case ZmqSocketType.Stream:
                    s = new Stream(parent, tid, sid);
                    break;
                default:
                    throw InvalidException.Create("type=" + type);
            }
            return s;
        }