public SimpleChat()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            try
            {
                m_service = new DNSSDService();
            }
            catch
            {
                MessageBox.Show("Bonjour Service is not available", "Error");
                Application.Exit();
            }

            m_eventManager = new DNSSDEventManager();
            m_eventManager.ServiceRegistered   += new _IDNSSDEvents_ServiceRegisteredEventHandler(this.ServiceRegistered);
            m_eventManager.ServiceFound        += new _IDNSSDEvents_ServiceFoundEventHandler(this.ServiceFound);
            m_eventManager.ServiceLost         += new _IDNSSDEvents_ServiceLostEventHandler(this.ServiceLost);
            m_eventManager.ServiceResolved     += new _IDNSSDEvents_ServiceResolvedEventHandler(this.ServiceResolved);
            m_eventManager.QueryRecordAnswered += new _IDNSSDEvents_QueryRecordAnsweredEventHandler(this.QueryAnswered);
            m_eventManager.OperationFailed     += new _IDNSSDEvents_OperationFailedEventHandler(this.OperationFailed);

            m_readMessageCallback = new ReadMessageCallback(OnReadMessage);

            this.Load += new System.EventHandler(this.Form1_Load);

            this.AcceptButton = button1;
        }
            /// <summary>
            /// Gets a number of log messages starting at the specified message id.
            /// </summary>
            /// <param name="fromId">Id of the message to start at.</param>
            /// <param name="count">Number of log messages to get.</param>
            /// <param name="callback">Callback to invoke for every read message</param>
            /// <returns>
            /// true, if reading ran to completion;
            /// false, if reading was cancelled.
            /// </returns>
            /// <exception cref="ArgumentOutOfRangeException"><paramref name="fromId"/> is not in the interval [OldestMessageId,NewestMessageId].</exception>
            /// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> must be positive.</exception>
            public override bool Read(long fromId, long count, ReadMessageCallback callback)
            {
                if (fromId < 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(fromId), fromId, "The log message id must be positive.");
                }
                if (fromId < OldestMessageId || fromId > NewestMessageId)
                {
                    throw new ArgumentOutOfRangeException(nameof(fromId), fromId, $"The log message id must be in the interval [{OldestMessageId},{NewestMessageId}].");
                }
                if (count < 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(count), count, "The number of log messages must be positive.");
                }

                mSelectContinuousMessagesCommand.Reset();
                mSelectContinuousMessagesCommand_FromIdParameter.Value = fromId;
                mSelectContinuousMessagesCommand_CountParameter.Value  = count;
                using (var reader = mSelectContinuousMessagesCommand.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        // read message and invoke processing callback
                        var message = ReadLogMessage(reader);
                        if (!callback(message))
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }
Exemple #3
0
        /// <summary>
        /// Gets a number of log messages starting at the specified message id.
        /// </summary>
        /// <param name="fromId">Id of the message to start at.</param>
        /// <param name="count">Number of log messages to get.</param>
        /// <param name="callback">Callback to invoke for every read message</param>
        /// <returns>
        /// true, if reading ran to completion;
        /// false, if reading was cancelled.
        /// </returns>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="fromId"/> is not in the interval [OldestMessageId,NewestMessageId].</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> must be positive.</exception>
        /// <exception cref="LogFileException">Reading failed (see inner exception for details).</exception>
        /// <exception cref="ObjectDisposedException">The log file has been disposed.</exception>
        public bool Read(long fromId, long count, ReadMessageCallback callback)
        {
            CheckDisposed();

            try
            {
                return(mDatabaseAccessor.Read(fromId, count, callback));
            }
            catch (SQLiteException ex)
            {
                throw new LogFileException(
                          $"Reading failed: {ex.Message}",
                          ex);
            }
        }
Exemple #4
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            registerServiceCallback = new RegisterServiceCallback(OnRegisterService);
            addPeerCallback         = new AddPeerCallback(OnAddPeer);
            removePeerCallback      = new RemovePeerCallback(OnRemovePeer);
            resolveServiceCallback  = new ResolveServiceCallback(OnResolveService);
            resolveAddressCallback  = new ResolveAddressCallback(OnResolveAddress);
            readMessageCallback     = new ReadMessageCallback(OnReadMessage);

            this.Load += new System.EventHandler(this.Form1_Load);

            this.AcceptButton = button1;
        }
Exemple #5
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            registerServiceCallback	= new RegisterServiceCallback(OnRegisterService);
            addPeerCallback			= new AddPeerCallback(OnAddPeer);
            removePeerCallback		= new RemovePeerCallback(OnRemovePeer);
            resolveServiceCallback	= new ResolveServiceCallback(OnResolveService);
            resolveAddressCallback	= new ResolveAddressCallback(OnResolveAddress);
            readMessageCallback		= new ReadMessageCallback(OnReadMessage);

            this.Load += new System.EventHandler(this.Form1_Load);

            this.AcceptButton = button1;
        }
Exemple #6
0
        public SimpleChat()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            try

            {

                m_service = new DNSSDService();

            }

            catch

            {

                MessageBox.Show("Bonjour Service is not available", "Error");

                Application.Exit();

            }

            m_eventManager = new DNSSDEventManager();

            m_eventManager.ServiceRegistered += new _IDNSSDEvents_ServiceRegisteredEventHandler(this.ServiceRegistered);

            m_eventManager.ServiceFound += new _IDNSSDEvents_ServiceFoundEventHandler(this.ServiceFound);

            m_eventManager.ServiceLost += new _IDNSSDEvents_ServiceLostEventHandler(this.ServiceLost);

            m_eventManager.ServiceResolved += new _IDNSSDEvents_ServiceResolvedEventHandler(this.ServiceResolved);

            m_eventManager.QueryRecordAnswered += new _IDNSSDEvents_QueryRecordAnsweredEventHandler(this.QueryAnswered);

            m_eventManager.OperationFailed += new _IDNSSDEvents_OperationFailedEventHandler(this.OperationFailed);

            m_readMessageCallback = new ReadMessageCallback(OnReadMessage);

            this.Load += new System.EventHandler(this.Form1_Load);

            this.AcceptButton = button1;
        }