Ejemplo n.º 1
0
        public ZMsg Request(string service, string token, ZMsg msg, int timeout = 2500)
        {
            IntPtr c_msg            = C.zmsg_new();
            IEnumerator <byte[]> fe = msg.GetEnumerator();

            while (fe.MoveNext())
            {
                IntPtr c_frame = ZMsg.ToZFramePtr(fe.Current);
                C.zmsg_push_back(c_msg, c_frame);
            }

            IntPtr res = C.zbuscli_request(this.connection.Handle, service, token, c_msg, timeout);

            if (res == IntPtr.Zero)
            {
                throw new ZBusException("request timeout");
            }

            ZMsg result = null;

            if (res != IntPtr.Zero)
            {
                result = ZMsg.ToZMsg(res);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public ZMsg Send(AsynCtrl ctrl, ZMsg msg)
        {
            IntPtr c_msg            = C.zmsg_new();
            IEnumerator <byte[]> fe = msg.GetEnumerator();

            while (fe.MoveNext())
            {
                IntPtr c_frame = ZMsg.ToZFramePtr(fe.Current);
                C.zmsg_push_back(c_msg, c_frame);
            }

            IntPtr c_ctrl = C.asyn_ctrl_new(ctrl.Service, ctrl.Token, ctrl.Timeout, ctrl.PeerId, ctrl.MessageId);
            IntPtr res    = C.zbuscli_send(this.connection.Handle, c_ctrl, c_msg);

            C.asyn_ctrl_destroy(out c_ctrl);

            if (res == IntPtr.Zero)
            {
                throw new ZBusException("send timeout");
            }

            ZMsg result = null;

            if (res != IntPtr.Zero)
            {
                result = ZMsg.ToZMsg(res);
            }

            return(result);
        }
Ejemplo n.º 3
0
        public int Send(ZMsg msg)
        {
            IntPtr c_msg            = C.zmsg_new();
            IEnumerator <byte[]> fe = msg.GetEnumerator();

            while (fe.MoveNext())
            {
                IntPtr c_frame = ZMsg.ToZFramePtr(fe.Current);
                C.zmsg_push_back(c_msg, c_frame);
            }
            int res = C.zbusconn_send(this._handle, c_msg);

            return(res);
        }
Ejemplo n.º 4
0
        public int Route(byte[] sockId, ZMsg msg)
        {
            IntPtr c_sock           = ZMsg.ToZFramePtr(sockId);
            IntPtr c_msg            = C.zmsg_new();
            IEnumerator <byte[]> fe = msg.GetEnumerator();

            while (fe.MoveNext())
            {
                IntPtr frame = ZMsg.ToZFramePtr(fe.Current);
                C.zmsg_push_back(c_msg, frame);
            }
            int res = C.zbusconn_route(this._handle, c_sock, c_msg);

            return(res);
        }
Ejemplo n.º 5
0
        public int Send(ZMsg msg)
        {
            IntPtr c_msg            = C.zmsg_new();
            IEnumerator <byte[]> fe = msg.GetEnumerator();

            while (fe.MoveNext())
            {
                IntPtr c_frame = ZMsg.ToZFramePtr(fe.Current);
                C.zmsg_push_back(c_msg, c_frame);
            }

            IntPtr c_sock_id, c_msg_id;

            c_sock_id = ZMsg.ToZFramePtr(this.RecvSockId);
            c_msg_id  = ZMsg.ToZFramePtr(this.RecvMsgId);

            C.zbuswrk_set_address(this._handle, c_sock_id, c_msg_id);

            return(C.zbuswrk_send(this.connection.Handle, this._handle, c_msg));
        }