示例#1
0
    public override void QueueEvents(RemoteEvent remoteEvent)
    {
        try
        {
            if (_eventManager == null)
            {
                var(auxHandle, ipAddress, portNumber, timeout) = ConnectionRequest();
                _eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber, timeout);
                _eventManager.Open();
                var dummy = _eventManager.StartWaitingForEvents(remoteEvent);
            }

            remoteEvent.LocalId++;

            var epb     = remoteEvent.BuildEpb();
            var epbData = epb.ToArray();

            Xdr.Write(IscCodes.op_que_events);
            Xdr.Write(_handle);
            Xdr.WriteBuffer(epbData);
            Xdr.Write(AddressOfAstRoutine);
            Xdr.Write(ArgumentToAstRoutine);
            Xdr.Write(remoteEvent.LocalId);

            Xdr.Flush();

            var response = (GenericResponse)ReadResponse();

            remoteEvent.RemoteId = response.ObjectHandle;
        }
        catch (IOException ex)
        {
            throw IscException.ForIOException(ex);
        }
    }
示例#2
0
 public override void CloseEventManager()
 {
     if (_eventManager != null)
     {
         _eventManager.Close();
         _eventManager = null;
     }
 }
示例#3
0
    public override async ValueTask CloseEventManagerAsync(CancellationToken cancellationToken = default)
    {
        if (_eventManager != null)
        {
            await _eventManager.CloseAsync(cancellationToken).ConfigureAwait(false);

            _eventManager = null;
        }
    }
示例#4
0
    public override async ValueTask DetachAsync(CancellationToken cancellationToken = default)
    {
        if (TransactionCount > 0)
        {
            throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);
        }

        try
        {
            await CloseEventManagerAsync(cancellationToken).ConfigureAwait(false);

            var detach = _handle != -1;
            if (detach)
            {
                await Xdr.WriteAsync(IscCodes.op_detach, cancellationToken).ConfigureAwait(false);

                await Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);
            }
            await Xdr.WriteAsync(IscCodes.op_disconnect, cancellationToken).ConfigureAwait(false);

            await Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);

            if (detach)
            {
                await ReadResponseAsync(cancellationToken).ConfigureAwait(false);
            }

            await CloseConnectionAsync(cancellationToken).ConfigureAwait(false);
        }
        catch (IOException ex)
        {
            try
            {
                await CloseConnectionAsync(cancellationToken).ConfigureAwait(false);
            }
            catch (IOException)
            { }
            throw IscException.ForIOException(ex);
        }
        finally
        {
            _connection      = null;
            Charset          = null;
            _eventManager    = null;
            ServerVersion    = null;
            Dialect          = 0;
            _handle          = -1;
            PacketSize       = 0;
            WarningMessage   = null;
            TransactionCount = 0;
        }
    }
示例#5
0
    public override void Detach()
    {
        if (TransactionCount > 0)
        {
            throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);
        }

        try
        {
            CloseEventManager();

            var detach = _handle != -1;
            if (detach)
            {
                Xdr.Write(IscCodes.op_detach);
                Xdr.Write(_handle);
            }
            Xdr.Write(IscCodes.op_disconnect);
            Xdr.Flush();
            if (detach)
            {
                ReadResponse();
            }

            CloseConnection();
        }
        catch (IOException ex)
        {
            try
            {
                CloseConnection();
            }
            catch (IOException)
            { }
            throw IscException.ForIOException(ex);
        }
        finally
        {
            _connection      = null;
            Charset          = null;
            _eventManager    = null;
            ServerVersion    = null;
            Dialect          = 0;
            _handle          = -1;
            PacketSize       = 0;
            WarningMessage   = null;
            TransactionCount = 0;
        }
    }
示例#6
0
    public override async ValueTask QueueEventsAsync(RemoteEvent remoteEvent, CancellationToken cancellationToken = default)
    {
        try
        {
            if (_eventManager == null)
            {
                var(auxHandle, ipAddress, portNumber, timeout) = await ConnectionRequestAsync(cancellationToken).ConfigureAwait(false);

                _eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber, timeout);
                await _eventManager.OpenAsync(cancellationToken).ConfigureAwait(false);

                var dummy = _eventManager.StartWaitingForEvents(remoteEvent);
            }

            remoteEvent.LocalId++;

            var epb     = remoteEvent.BuildEpb();
            var epbData = epb.ToArray();

            await Xdr.WriteAsync(IscCodes.op_que_events, cancellationToken).ConfigureAwait(false);

            await Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);

            await Xdr.WriteBufferAsync(epbData, cancellationToken).ConfigureAwait(false);

            await Xdr.WriteAsync(AddressOfAstRoutine, cancellationToken).ConfigureAwait(false);

            await Xdr.WriteAsync(ArgumentToAstRoutine, cancellationToken).ConfigureAwait(false);

            await Xdr.WriteAsync(remoteEvent.LocalId, cancellationToken).ConfigureAwait(false);

            await Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);

            var response = (GenericResponse) await ReadResponseAsync(cancellationToken).ConfigureAwait(false);

            remoteEvent.RemoteId = response.ObjectHandle;
        }
        catch (IOException ex)
        {
            throw IscException.ForIOException(ex);
        }
    }