Beispiel #1
0
        public void QueueEvents(RemoteEvent events)
        {
            if (this.eventManager == null)
            {
                string ipAddress = string.Empty;
                int portNumber = 0;
                int auxHandle = 0;

                this.ConnectionRequest(out auxHandle, out ipAddress, out portNumber);

                this.eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
            }

            lock (this.SyncObject)
            {
                try
                {
                    events.LocalId = ++this.eventsId;

                    EventParameterBuffer epb = events.ToEpb();

                    this.Write(IscCodes.op_que_events); // Op codes
                    this.Write(this.handle);			// Database	object id
                    this.WriteBuffer(epb.ToArray());	// Event description block
                    this.Write(0);						// Address of ast routine
                    this.Write(0);						// Argument	to ast routine
                    this.Write(events.LocalId);		    // Client side id of remote	event

                    this.Flush();

                    GenericResponse response = (GenericResponse)this.ReadResponse();

                    // Update event	Remote event ID
                    events.RemoteId = response.ObjectHandle;

                    // Enqueue events in the event manager
                    this.eventManager.QueueEvents(events);
                }
                catch (IOException)
                {
                    throw new IscException(IscCodes.isc_net_read_err);
                }
            }
        }
		public void QueueEvents(RemoteEvent events)
		{
			if (_eventManager == null)
			{
				string ipAddress = string.Empty;
				int portNumber = 0;
				int auxHandle = 0;

				ConnectionRequest(out auxHandle, out ipAddress, out portNumber);

				_eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
			}

			lock (SyncObject)
			{
				try
				{
					events.LocalId = Interlocked.Increment(ref _eventsId);

					// Enqueue events in the event manager
					_eventManager.QueueEvents(events);

					EventParameterBuffer epb = events.ToEpb();

					XdrStream.Write(IscCodes.op_que_events);
					XdrStream.Write(_handle);                 // Database object id
					XdrStream.WriteBuffer(epb.ToArray());     // Event description block
					XdrStream.Write(0);                       // Address of ast routine
					XdrStream.Write(0);                       // Argument to ast routine
					XdrStream.Write(events.LocalId);          // Client side id of remote event

					XdrStream.Flush();

					GenericResponse response = (GenericResponse)ReadResponse();

					// Update event	Remote event ID
					events.RemoteId = response.ObjectHandle;
				}
				catch (IOException ex)
				{
					throw IscException.ForErrorCode(IscCodes.isc_net_read_err, ex);
				}
			}
		}