Inheritance: IDisposable
示例#1
0
 //public XmlRpcValue stickaroundyouwench = null;
 public PendingConnection(XmlRpcClient client, Subscription s, string uri, XmlRpcValue chk)
 {
     this.client = client;
     this.chk = chk;
     parent = s;
     RemoteUri = uri;
 }
示例#2
0
 public void AddSource(XmlRpcClient source, int eventMask)
 {
     addsource(instance, source.instance, (uint) eventMask);
 }
示例#3
0
 public void SetSourceEvents(XmlRpcClient source, int eventMask)
 {
     setsourceevents(instance, source.instance, (uint)eventMask);
 }
示例#4
0
 public void RemoveSource(XmlRpcClient source)
 {
     source.SegFault();
     removesource(instance, source.instance);
 }
示例#5
0
 public void AddSource(XmlRpcClient source, int eventMask)
 {
     addsource(instance, source.instance, (uint)eventMask);
 }
示例#6
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     lock (busyMutex)
     {
         if (refs != 0)
             throw new Exception("XmlRpcClient disposed while in use!");
     }
     if (client != null)
     {
         client.Dispose();
         client = null;
     }
 }
示例#7
0
 private CachedXmlRpcClient(XmlRpcClient c)
 {
     client = c;
 }
示例#8
0
 public XmlRpcClient getXMLRPCClient(string host, int port, string uri)
 {
     XmlRpcClient c = null;
     lock (clients_mutex)
     {
         List<CachedXmlRpcClient> zombies = new List<CachedXmlRpcClient>();
         foreach (CachedXmlRpcClient client in clients)
         {
             if (!client.in_use)
             {
                 if (client.client.Host == host && client.client.Port == port && client.client.Uri == uri)
                 {
                     c = client.client;
                     client.in_use = true;
                     client.last_use_time = DateTime.Now;
                     break;
                 }
                 else if (DateTime.Now.Subtract(client.last_use_time).TotalSeconds > 30 ||
                          !client.client.IsConnected)
                 {
                     client.client.Shutdown();
                     zombies.Add(client);
                 }
             }
         }
         clients = clients.Except(zombies).ToList();
     }
     if (c == null)
     {
         c = new XmlRpcClient(host, port, uri);
         clients.Add(new CachedXmlRpcClient(c) {in_use = true, last_use_time = DateTime.Now});
     }
     return c;
 }
示例#9
0
 private CachedXmlRpcClient(XmlRpcClient c)
 {
     lock (client_lock)
     {
         client = c;
         client.Disposed += () =>
                                {
                                    client = null;
                                };
     }
 }
示例#10
0
 /// <summary>
 ///     Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     lock (busyMutex)
     	if (refs != 0)
         	EDB.WriteLine("warning: XmlRpcClient disposed with "+refs+" refs held");
     lock (client_lock)
     {
         if (client != null)
         {
             client.Dispose();
             client = null;
         }
     }
 }
示例#11
0
 //public XmlRpcValue stickaroundyouwench = null;
 public PendingConnection(XmlRpcClient client, string uri)
 {
     this.client = client;
     RemoteUri = uri;
 }
示例#12
0
 public CachedXmlRpcClient(XmlRpcClient c)
 {
     client = c;
 }
示例#13
0
 public void releaseXMLRPCClient(XmlRpcClient client)
 {
     lock (clients_mutex)
     {
         foreach (CachedXmlRpcClient c in clients)
         {
             if (client == c.client)
             {
                 c.in_use = false;
                 break;
             }
         }
     }
 }
示例#14
0
 public void RemoveSource(XmlRpcClient source)
 {
     source.SegFault();
     removesource(instance, source.instance);
 }
示例#15
0
 public void Dispose()
 {
     chk = null; //.Dispose();
     client.Dispose();
     client = null;
 }
示例#16
0
 public void SetSourceEvents(XmlRpcClient source, int eventMask)
 {
     setsourceevents(instance, source.instance, (uint) eventMask);
 }
示例#17
0
 public XmlRpcClient getXMLRPCClient(string host, int port, string uri)
 {
     XmlRpcClient c = null;
     lock (clients_mutex)
     {
         List<CachedXmlRpcClient> zombies = new List<CachedXmlRpcClient>();
         foreach (CachedXmlRpcClient client in clients)
         {
             if (!client.in_use)
             {
                 if (DateTime.Now.Subtract(client.last_use_time).TotalSeconds > 30 ||
                     !client.client.IsConnected)
                 {
                     client.client.Shutdown();
                     zombies.Add(client);
                 }
                 else if (client.client.CheckIdentity(host, port, uri))
                 {
                     c = client.client;
                     client.in_use = true;
                     client.last_use_time = DateTime.Now;
                     break;
                 }
             }
         }
         foreach (CachedXmlRpcClient C in zombies)
         {
             clients.Remove(C);
             C.client.Dispose();
         }
         if (c == null)
         {
             c = new XmlRpcClient(host, port, uri);
             clients.Add(new CachedXmlRpcClient(c) {in_use = true, last_use_time = DateTime.Now});
         }
     }
     return c;
 }