示例#1
0
        public override List <Advertisement> GetLocalAdvertisements(int type, string attr, string value)
        {
            JxtaVector advs = new JxtaVector();

            Errors.check(discovery_service_get_local_advertisements(self, type, attr, value, ref advs.self));

            List <Advertisement> list = new List <Advertisement>();

            for (int i = 0; i < advs.Length; i++)
            {
                string advType = Marshal.PtrToStringAnsi(jxta_advertisement_get_document_name(advs[i]));

                advType = advType.Replace("jxta:", "");

                if (advType == "PA")
                {
                    advType = "PeerAdvertisement";
                }

                Type instanceType =
                    System.Reflection.Assembly.GetExecutingAssembly().GetType("JxtaNET." + advType, false, true);

                Advertisement adv = (Advertisement)System.Activator.CreateInstance(instanceType,
                                                                                   new object[] { advs[i] });

                list.Add(adv);
            }

            return(list);
        }
示例#2
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);
            }
        }
示例#3
0
 public JxtaVectorEnumerator(JxtaVector vec)
 {
     this.vec        = vec;
     this.enumerator = -1;
 }