]> git.meshlink.io Git - catta/blobdiff - avahi-sharp/Client.cs
Add a new documentation file telling distributors how to get full build system
[catta] / avahi-sharp / Client.cs
index cc77cf870e0100fa1c8da4b22c9065591f70425b..01b08bd5934c9e8eae4c126548151ed579a80f82 100644 (file)
@@ -43,20 +43,42 @@ namespace Avahi
     internal delegate int PollCallback (IntPtr ufds, uint nfds, int timeout);
     internal delegate void ClientCallback (IntPtr client, ClientState state, IntPtr userData);
 
-    public delegate void ClientStateHandler (object o, ClientState state);
+    public delegate void ClientStateHandler (object o, ClientStateArgs state);
 
+    public class ClientStateArgs : EventArgs
+    {
+        private ClientState state;
+
+        public ClientState State
+        {
+            get { return state; }
+        }
+
+        public ClientStateArgs (ClientState state)
+        {
+            this.state = state;
+        }
+    }
+    
     public enum Protocol {
         Unspecified = -1,
         IPv4 = 0,
         IPv6 = 1
     }
-    
-    public enum ClientState {
+
+    internal enum ServerState {
         Invalid,
         Registering,
         Running,
-        Collision,
-        Disconnected = 100
+        Collision
+    }
+    
+    public enum ClientState {
+        Registering = ServerState.Registering,
+        Running = ServerState.Running,
+        Collision = ServerState.Collision,
+        Failure = 100,
+        Connecting = 101
     }
 
     [Flags]
@@ -76,6 +98,13 @@ namespace Avahi
         Local = 8,
         OurOwn = 16,
     }
+
+    [Flags]
+    public enum ClientFlags {
+        None = 0,
+        IgnoreUserConfig = 1,
+        NoFail = 2
+    }
     
     public class Client : IDisposable
     {
@@ -87,7 +116,7 @@ namespace Avahi
         private Thread thread;
 
         [DllImport ("avahi-client")]
-        private static extern IntPtr avahi_client_new (IntPtr poll, ClientCallback handler,
+        private static extern IntPtr avahi_client_new (IntPtr poll, ClientFlags flags, ClientCallback handler,
                                                        IntPtr userData, out int error);
 
         [DllImport ("avahi-client")]
@@ -206,7 +235,7 @@ namespace Avahi
             }
         }
 
-        public Client ()
+        public Client (ClientFlags flags)
         {
             spoll = avahi_simple_poll_new ();
 
@@ -216,7 +245,7 @@ namespace Avahi
             cb = OnClientCallback;
 
             int error;
-            handle = avahi_client_new (poll, cb, IntPtr.Zero, out error);
+            handle = avahi_client_new (poll, flags, cb, IntPtr.Zero, out error);
             if (error != 0)
                 throw new ClientException (error);
 
@@ -225,6 +254,9 @@ namespace Avahi
             thread.Start ();
         }
 
+        public Client () : this (ClientFlags.None) {
+        }
+
         ~Client ()
         {
             Dispose ();
@@ -251,7 +283,7 @@ namespace Avahi
         private void OnClientCallback (IntPtr client, ClientState state, IntPtr userData)
         {
             if (StateChanged != null)
-                StateChanged (this, state);
+                StateChanged (this, new ClientStateArgs (state));
         }
 
         private int OnPollCallback (IntPtr ufds, uint nfds, int timeout) {