Exemplo n.º 1
0
        public Client(ClientFlags flags)
        {
            spoll = avahi_simple_poll_new();

            pollcb = OnPollCallback;
            avahi_simple_poll_set_func(spoll, pollcb);
            IntPtr poll = avahi_simple_poll_get(spoll);

            cb = OnClientCallback;

            int error;

            handle = avahi_client_new(poll, flags, cb, IntPtr.Zero, out error);
            if (error != 0)
            {
                throw new ClientException(error);
            }

            thread = new Thread(PollLoop);
            thread.IsBackground = true;
            thread.Start();
        }
Exemplo n.º 2
0
 private static extern void avahi_simple_poll_set_func(IntPtr spoll, PollCallback cb);
Exemplo n.º 3
0
        public Client (ClientFlags flags)
        {
            spoll = avahi_simple_poll_new ();

            pollcb = OnPollCallback;
            avahi_simple_poll_set_func (spoll, pollcb);
            IntPtr poll = avahi_simple_poll_get (spoll);
            cb = OnClientCallback;

            int error;
            handle = avahi_client_new (poll, flags, cb, IntPtr.Zero, out error);
            if (error != 0)
                throw new ClientException (error);

            thread = new Thread (PollLoop);
            thread.IsBackground = true;
            thread.Start ();
        }
Exemplo n.º 4
0
 private static extern void avahi_simple_poll_set_func (IntPtr spoll, PollCallback cb);
Exemplo n.º 5
0
 public void Enqueue(List<ProducerChannel> list, PollCallback cb)
 {
     try
     {
         Queue.Enqueue(new PrismPollItem(JsonConvert.SerializeObject(list), cb));
         ProcessQueue();
     }
     catch (SystemException e)
     {
         System.Diagnostics.Debug.WriteLine(e.ToString());
         cb(e.ToString(), new List<ProducerChannelValue>());
     }
 }
Exemplo n.º 6
0
        public int AddPoll(int delayInMilliseconds, byte slaveAddress, byte register, int numRegisters, PollCallback pollCallback, object data)
        {
            lock (socketLock)
            {
                string request = String.Format("addpoll {0} {1} {2} {3}", delayInMilliseconds, slaveAddress, register, numRegisters);
                SendLine(request);
                string response = ReadLine();

                var match = Regex.Match(response, "OK (\\d+)");
                if (!match.Success)
                {
                    throw new I2CException(String.Format("Unexpected response '{0}'", response));
                }

                int pollID = int.Parse(match.Groups[1].Value);

                pollEntries.Add(pollID, new PollEntry()
                {
                    PollID = pollID, Delay = delayInMilliseconds, I2CAddress = slaveAddress, Register = register, NumRegisters = numRegisters, Callback = pollCallback, Data = data
                });

                return(pollID);
            }
        }
Exemplo n.º 7
0
        public int AddPoll(int delayInMilliseconds, byte slaveAddress, byte register, int numRegisters, PollCallback pollCallback, object data)
        {
            lock (socketLock)
            {
                string request = String.Format("addpoll {0} {1} {2} {3}", delayInMilliseconds, slaveAddress, register, numRegisters);
                SendLine(request);
                string response = ReadLine();

                var match = Regex.Match(response, "OK (\\d+)");
                if (!match.Success) throw new I2CException(String.Format("Unexpected response '{0}'", response));

                int pollID = int.Parse(match.Groups[1].Value);

                pollEntries.Add(pollID, new PollEntry() { PollID = pollID, Delay = delayInMilliseconds, I2CAddress = slaveAddress, Register = register, NumRegisters = numRegisters, Callback = pollCallback, Data = data });

                return pollID;
            }
        }