Esempio n. 1
0
 public Task InvokeAsync(
     ConnectorContext context,
     IProvisionedSignal provisionedSignal,
     CancellationToken cancellationToken = default)
 {
     return(Task.CompletedTask);
 }
Esempio n. 2
0
        private void ConnectCallback(IAsyncResult ar)
        {
            ConnectorContext connector = (ConnectorContext)ar.AsyncState;

            try
            {
                connector.Socket.EndConnect(ar);
            }
            catch (Exception ex)
            {
                EndConnect(ex, connector);
                return;
            }

            SocketAsyncEventArgs readBuffer = new SocketAsyncEventArgs();

            readBuffer.SetBuffer(new Byte[SessionConfig.ReadBufferSize], 0, SessionConfig.ReadBufferSize);
            readBuffer.Completed += new EventHandler <SocketAsyncEventArgs>(SocketAsyncEventArgs_Completed);

            SocketAsyncEventArgs writeBuffer = new SocketAsyncEventArgs();

            writeBuffer.SetBuffer(new Byte[SessionConfig.ReadBufferSize], 0, SessionConfig.ReadBufferSize);
            writeBuffer.Completed += new EventHandler <SocketAsyncEventArgs>(SocketAsyncEventArgs_Completed);

            EndConnect(new AsyncDatagramSession(this, Processor, connector.Socket, connector.RemoteEP,
                                                new SocketAsyncEventArgsBuffer(readBuffer), new SocketAsyncEventArgsBuffer(writeBuffer),
                                                ReuseBuffer), connector);
        }
Esempio n. 3
0
    public ConnectorContext connector()
    {
        ConnectorContext _localctx = new ConnectorContext(Context, State);

        EnterRule(_localctx, 10, RULE_connector);
        int _la;

        try {
            EnterOuterAlt(_localctx, 1);
            {
                State = 40;
                _la   = TokenStream.LA(1);
                if (!(_la == T__6 || _la == T__7))
                {
                    ErrorHandler.RecoverInline(this);
                }
                else
                {
                    ErrorHandler.ReportMatch(this);
                    Consume();
                }
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }
Esempio n. 4
0
 /// <summary>
 /// Initializes the job synchronizing the project details
 /// </summary>
 /// <param name="projectService"><see cref="IProjectService"/></param>
 /// <param name="sisProjectService"><see cref="ISisProjectService"/></param>
 /// <param name="mspProjectService"><see cref="IMspProjectService"/></param>
 /// <param name="context"><see cref="ConnectorContext"/></param>
 public ProjectSyncJob(IProjectService projectService, ISisProjectService sisProjectService, IMspProjectService mspProjectService, ConnectorContext context)
 {
     _sisProjectService = sisProjectService;
     _mspProjectService = mspProjectService;
     _projectService    = projectService;
     _context           = context;
 }
Esempio n. 5
0
        private void ProcessConnect(SocketAsyncEventArgs e)
        {
            ConnectorContext connector = (ConnectorContext)e.UserToken;

            if (e.SocketError == SocketError.Success)
            {
                SocketAsyncEventArgs readBuffer = e;
                readBuffer.AcceptSocket   = null;
                readBuffer.RemoteEndPoint = null;
                readBuffer.SetBuffer(new Byte[SessionConfig.ReadBufferSize], 0, SessionConfig.ReadBufferSize);

                SocketAsyncEventArgs writeBuffer = new SocketAsyncEventArgs();
                writeBuffer.SetBuffer(new Byte[SessionConfig.ReadBufferSize], 0, SessionConfig.ReadBufferSize);
                writeBuffer.Completed += new EventHandler <SocketAsyncEventArgs>(SocketAsyncEventArgs_Completed);

                try
                {
                    EndPoint localEP  = connector.Socket.LocalEndPoint;
                    EndPoint remoteEP = connector.Socket.RemoteEndPoint;
                    EndConnect(new AsyncSocketSession(this, Processor, connector.Socket, localEP, remoteEP,
                                                      new SocketAsyncEventArgsBuffer(readBuffer), new SocketAsyncEventArgsBuffer(writeBuffer),
                                                      ReuseBuffer), connector);
                }
                catch (Exception ex)
                {
                    Util.ExceptionMonitor.Instance.ExceptionCaught(ex);
                }
            }
            else
            {
                EndConnect(new SocketException((Int32)e.SocketError), connector);
            }
        }
Esempio n. 6
0
        public StatelessLinkConnector(string name, ConnectorContext context) : base(name, context)
        {
            _context = new InstanceContext(context.ChainName, Name, context.ChainConfiguration);

            using var serviceScope = context.ApplicationServices.CreateScope();
            InstanceFactory.Create <TLink>(serviceScope.ServiceProvider, _context).Dispose();
        }
Esempio n. 7
0
 public override Task <bool> ValidateAsync(
     ConnectorContext context,
     DeprovisionSignal signal,
     CancellationToken cancellationToken = default)
 {
     return(Task.FromResult(true));
 }
Esempio n. 8
0
 protected Connector(string name, ConnectorContext context)
 {
     Name           = name;
     InputType      = typeof(TInput);
     OutputType     = typeof(TOutput);
     _context       = context;
     (Index, Depth) = context.Add(this);
 }
 protected override void BeginConnect(ConnectorContext connector)
 {
     /*
      * No idea why get a SocketError.InvalidArgument in ConnectAsync.
      * Call BeginConnect instead.
      */
     connector.Socket.BeginConnect(connector.RemoteEP, ConnectCallback, connector);
 }
Esempio n. 10
0
 /// <inheritdoc/>
 protected override void BeginConnect(ConnectorContext connector)
 {
     /*
      * No idea why get a SocketError.InvalidArgument in ConnectAsync.
      * Call BeginConnect instead.
      */
     connector.Socket.BeginConnect(connector.RemoteEP, ConnectCallback, connector);
 }
Esempio n. 11
0
        public StatefulLinkConnector(string name, ConnectorContext context) : base(name, context)
        {
            var instanceContext = new InstanceContext(context.ChainName, Name, context.ChainConfiguration);

            _link = InstanceFactory.Create <TLink>(context.ApplicationServices, instanceContext);

            context.AddInit(_link.InitAsync);
        }
 protected override IConnectFuture Connect0(EndPoint remoteEP, EndPoint localEP, Action<IoSession, IConnectFuture> sessionInitializer)
 {
     System.Net.Sockets.Socket socket = NewSocket(remoteEP.AddressFamily);
     if (localEP != null)
         socket.Bind(localEP);
     ConnectorContext ctx = new ConnectorContext(socket, remoteEP, sessionInitializer);
     BeginConnect(ctx);
     return ctx.Future;
 }
Esempio n. 13
0
 public async Task InvokeAsync(
     ConnectorContext context,
     DeprovisionSignal deprovisionSignal,
     CancellationToken cancellationToken = default)
 {
     await Agent
     .GetStateEngine <TypeState, TypeState>()
     .DeleteMachineAsync(context.Machine.MachineId, cancellationToken);
 }
Esempio n. 14
0
 /// <inheritdoc/>
 protected override void BeginConnect(ConnectorContext connector)
 {
     SocketAsyncEventArgs e = new SocketAsyncEventArgs();
     e.Completed += new EventHandler<SocketAsyncEventArgs>(SocketAsyncEventArgs_Completed);
     e.RemoteEndPoint = connector.RemoteEP;
     e.UserToken = connector;
     Boolean willRaiseEvent = connector.Socket.ConnectAsync(e);
     if (!willRaiseEvent)
         ProcessConnect(e);
 }
Esempio n. 15
0
        /// <inheritdoc/>
        protected override IConnectFuture Connect0(EndPoint remoteEP, EndPoint localEP, Action <IoSession, IConnectFuture> sessionInitializer)
        {
            System.Net.Sockets.Socket socket = NewSocket(remoteEP.AddressFamily);
            if (localEP != null)
            {
                socket.Bind(localEP);
            }
            ConnectorContext ctx = new ConnectorContext(socket, remoteEP, sessionInitializer);

            BeginConnect(ctx);
            return(ctx);
        }
Esempio n. 16
0
 public async Task InvokeAsync(
     ConnectorContext context,
     ReserveSignal reserveSignal,
     CancellationToken cancellationToken = default)
 {
     await context.Machine.SignalAsync(
         new ProvisioningCompleteSignal
     {
         Reservation = reserveSignal
     },
         cancellationToken);
 }
        protected void EndConnect(IoSession session, ConnectorContext connector)
        {
            try
            {
                InitSession(session, connector.Future, connector.SessionInitializer);
                session.Processor.Add(session);
            }
            catch (Exception ex)
            {
                ExceptionMonitor.Instance.ExceptionCaught(ex);
            }

            _processor.IdleStatusChecker.Start();
        }
Esempio n. 18
0
        /// <inheritdoc/>
        protected override void BeginConnect(ConnectorContext connector)
        {
            SocketAsyncEventArgs e = new SocketAsyncEventArgs();

            e.Completed     += new EventHandler <SocketAsyncEventArgs>(SocketAsyncEventArgs_Completed);
            e.RemoteEndPoint = connector.RemoteEP;
            e.UserToken      = connector;
            Boolean willRaiseEvent = connector.Socket.ConnectAsync(e);

            if (!willRaiseEvent)
            {
                ProcessConnect(e);
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Ends connecting.
        /// </summary>
        /// <param name="session">the connected session</param>
        /// <param name="connector">the context of current connector</param>
        protected void EndConnect(IoSession session, ConnectorContext connector)
        {
            try
            {
                InitSession(session, connector, connector.SessionInitializer);
                session.Processor.Add(session);
            }
            catch (Exception ex)
            {
                ExceptionMonitor.Instance.ExceptionCaught(ex);
            }

            _processor.IdleStatusChecker.Start();
        }
Esempio n. 20
0
        private void ConnectCallback(IAsyncResult ar)
        {
            ConnectorContext connector = (ConnectorContext)ar.AsyncState;

            try
            {
                connector.Socket.EndConnect(ar);
            }
            catch (Exception ex)
            {
                EndConnect(ex, connector);
                return;
            }

            EndConnect(new AsyncSocketSession(this, Processor, connector.Socket, ReuseBuffer), connector);
        }
Esempio n. 21
0
        /// <summary>
        /// Dispatches the domain events
        /// </summary>
        /// <param name="mediator"><see cref="IMediator"/></param>
        /// <param name="ctx"><see cref="ConnectorContext"/></param>
        public static void DispatchDomainEvents(this IMediator mediator, ConnectorContext ctx)
        {
            var domainEntities = ctx.ChangeTracker
                                 .Entries <Entity>()
                                 .Where(x => x.Entity.DomainEvents != null && x.Entity.DomainEvents.Any()).ToList();

            var domainEvents = domainEntities
                               .SelectMany(x => x.Entity.DomainEvents)
                               .ToList();

            domainEntities.ToList()
            .ForEach(entity => entity.Entity.ClearDomainEvents());

            foreach (var domainEvent in domainEvents)
            {
                mediator.Publish(domainEvent);
            }
        }
Esempio n. 22
0
        private void ProcessConnect(SocketAsyncEventArgs e)
        {
            ConnectorContext connector = (ConnectorContext)e.UserToken;

            if (e.SocketError == SocketError.Success)
            {
                SocketAsyncEventArgs readBuffer = e;
                readBuffer.AcceptSocket   = null;
                readBuffer.RemoteEndPoint = null;
                readBuffer.SetBuffer(new Byte[SessionConfig.ReadBufferSize], 0, SessionConfig.ReadBufferSize);

                SocketAsyncEventArgs writeBuffer = new SocketAsyncEventArgs();
                writeBuffer.SetBuffer(new Byte[SessionConfig.ReadBufferSize], 0, SessionConfig.ReadBufferSize);
                writeBuffer.Completed += new EventHandler <SocketAsyncEventArgs>(SocketAsyncEventArgs_Completed);

                EndConnect(new AsyncSocketSession(this, Processor, connector.Socket,
                                                  new SocketAsyncEventArgsBuffer(readBuffer), new SocketAsyncEventArgsBuffer(writeBuffer),
                                                  ReuseBuffer), connector);
            }
            else
            {
                EndConnect(new SocketException((Int32)e.SocketError), connector);
            }
        }
Esempio n. 23
0
 public TestInspectConnector(InitAction?onInit, ConnectorContext context) : base(nameof(TestInspectConnector <T>), context)
 {
     if (onInit is {})
Esempio n. 24
0
 public MappingConnector(MapperDelegate <TInput, TOutput> function, ConnectorContext context) : base(GetFunctionName(function), context)
 {
     _function = function;
 }
 public ConditionalSubChainConnector(Predicate <TInput> predicate, Action <IConnectorLinker <TInput> > buildChain,
                                     ConnectorContext context) : base("Conditional", context)
 {
     _predicate            = predicate;
     _conditionalConnector = ConnectorLinker <TInput> .CreateAndBuild(buildChain, context);
 }
Esempio n. 26
0
 public EnumerationConnector(Action <IConnectorLinker <T> > buildChain, ConnectorContext context) : base("Enumerate", context)
 {
     _connector = ConnectorLinker <T> .CreateAndBuild(buildChain, context);
 }
Esempio n. 27
0
 public Services(ConnectorContext context)
     : base(context)
 {
 }
Esempio n. 28
0
 /// <summary>
 /// Ends connecting.
 /// </summary>
 /// <param name="cause">the exception occurred</param>
 /// <param name="connector">the context of current connector</param>
 protected void EndConnect(Exception cause, ConnectorContext connector)
 {
     connector.Exception = cause;
     connector.Socket.Close();
 }
Esempio n. 29
0
 public CompletionConnector(string reason, ConnectorContext context) : base("Completion", context)
 {
     _reason = reason;
 }
Esempio n. 30
0
 /// <summary>
 /// Begins connecting.
 /// </summary>
 /// <param name="connector">the context of current connector</param>
 protected abstract void BeginConnect(ConnectorContext connector);
Esempio n. 31
0
 public DelayConnector(int millisecondsDelay, ConnectorContext context) : base(nameof(DelayConnector <T>), context)
 {
     _millisecondsDelay = millisecondsDelay;
 }
 protected abstract void BeginConnect(ConnectorContext connector);
Esempio n. 33
0
 public Services(ConnectorContext context)
 {
     this.context = context;
 }
 protected void EndConnect(Exception cause, ConnectorContext connector)
 {
     connector.Future.Exception = cause;
     connector.Socket.Close();
 }
 /// <inheritdoc/>
 protected override void BeginConnect(ConnectorContext connector)
 {
     connector.Socket.BeginConnect(connector.RemoteEP, ConnectCallback, connector);
 }
 /// <inheritdoc/>
 protected override void BeginConnect(ConnectorContext connector)
 {
     connector.Socket.BeginConnect(connector.RemoteEP, ConnectCallback, connector);
 }
Esempio n. 37
0
 public SubChainConnector(Action <IConnectorLinker <TInput> > buildChain, ConnectorContext context) : base("SubChain", context)
 {
     _connector = ConnectorLinker <TInput> .CreateAndBuild(buildChain, context);
 }