Esempio n. 1
0
        /// <summary>
        ///  Try to synchronously connect to the remote end of a pipe.
        ///  If peers is set to a vector containing a list of peers,
        ///  the connection will be attempted to be established with the listed
        ///  peer(s). The number of peers that the vector may contain depends on
        ///  the type of type. Unicast typically can only connect to a single peer.
        /// </summary>
        /// <param name="adv">Pipe Advertisement</param>
        /// <param name="timeout">timeout in micro-seconds</param>
        /// <param name="peers">optional vector of peers</param>
        /// <returns></returns>
        internal Pipe TimedConnect(PipeAdvertisement adv, long timeout, List <Peer> peers)
        {
            IntPtr ret = new IntPtr();

            if (peers != null)
            {
                JxtaVector jVec = new JxtaVector();

                jVec.self = jxta_vector_new(0);

                foreach (Peer peer in peers)
                {
                    jVec.Add(peer.self);
                }

                jxta_pipe_service_timed_connect(this.self, adv.self, timeout, jVec.self, ref ret);
            }
            else
            {
                jxta_pipe_service_timed_connect(this.self, adv.self, timeout, IntPtr.Zero, ref ret);
            }

            if (ret != IntPtr.Zero)
            {
                return(new Pipe(ret, adv));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Accept an incoming connection.
        /// This function waits until the pipe is ready to receive messages, or until
        /// the timeout is reached. The semantics of being ready to receive messages
        /// depends on the type of pipe. After the first call to connect, the pipe
        /// is set to wait for connection request. If a connection request arrives after
        /// the timeout has been reached, it will be queued up, and a following call to
        /// TimedAccept() will retrieve the connection request, until the pipe is released.
        /// </summary>
        /// <param name="adv">Pipe Advertisment of the pipe to connect to.</param>
        /// <param name="timeout">timeout in micro-seconds</param>
        /// <returns></returns>
        internal Pipe TimedAccept(PipeAdvertisement adv, long timeout)
        {
            IntPtr ret = new IntPtr();

            Errors.check(jxta_pipe_service_timed_accept(this.self, adv.self, timeout, ref ret));
            return(new Pipe(ret, adv));
        }
Esempio n. 3
0
        public InputPipe CreateInputPipe(PipeAdvertisement adv, PipeMsgListener pipeListener)
        {
            InputPipeImpl pipe = (InputPipeImpl)CreateInputPipe(adv);

            pipe.AddListener(pipeListener);

            return(pipe);
        }
Esempio n. 4
0
        public OutputPipe CreateOutputPipe(PipeAdvertisement adv, long timeout)
        {
            Pipe pipe = new Pipe();

            if (_pipeDictionary.TryGetValue(adv, out pipe) == true)
            {
                return(pipe.OutputPipe);
            }

            pipe = TimedConnect(adv, timeout * 1000, null);
            _pipeDictionary.Add(adv, pipe);

            return((pipe != null) ? pipe.OutputPipe : null);
        }
Esempio n. 5
0
        public InputPipe CreateInputPipe(PipeAdvertisement adv)
        {
            Pipe pipe = new Pipe();

            if (_pipeDictionary.TryGetValue(adv, out pipe) == true)
            {
                return(pipe.InputPipe);
            }

            pipe = TimedAccept(adv, 1000);
            _pipeDictionary.Add(adv, pipe);

            return(pipe.InputPipe);
        }
Esempio n. 6
0
 internal Pipe(IntPtr self, PipeAdvertisement a)
     : base(self)
 {
     adv = a;
 }
Esempio n. 7
0
 internal InputPipeImpl(IntPtr self, PipeAdvertisement a)
     : base(self)
 {
     adv = a;
 }