Ejemplo n.º 1
0
            public Task ConnectAsync(Node node)
            {
                if (_isFailing)
                {
                    throw new InvalidOperationException("making it fail");
                }

                lock (this)
                {
                    ConnectAsyncCallsCount++;
                }

                var session = new Session(30313, LimboLogs.Instance, Substitute.For <IChannel>(), node);

                lock (_sessions)
                {
                    _sessions.Add(session);
                }

                SessionCreated?.Invoke(this, new SessionEventArgs(session));
                return(Task.CompletedTask);
            }
Ejemplo n.º 2
0
        private void InitializeChannel(IChannel channel, ISession session)
        {
            if (session.Direction == ConnectionDirection.In)
            {
                Metrics.IncomingConnections++;
            }
            else
            {
                Metrics.OutgoingConnections++;
            }

            if (_logger.IsTrace)
            {
                _logger.Trace($"|NetworkTrace| Initializing {session} channel");
            }

            _sessionMonitor.AddSession(session);
            session.Disconnected += SessionOnPeerDisconnected;
            SessionCreated?.Invoke(this, new SessionEventArgs(session));

            HandshakeRole role             = session.Direction == ConnectionDirection.In ? HandshakeRole.Recipient : HandshakeRole.Initiator;
            var           handshakeHandler = new NettyHandshakeHandler(_encryptionHandshakeService, session, role, session.RemoteNodeId, _logManager, _group);

            IChannelPipeline pipeline = channel.Pipeline;

            // pipeline.AddLast(new LoggingHandler(session.Direction.ToString().ToUpper(), DotNetty.Handlers.Logging.LogLevel.TRACE));
            pipeline.AddLast("enc-handshake-dec", new LengthFieldBasedFrameDecoder(ByteOrder.BigEndian, ushort.MaxValue, 0, 2, 0, 0, true));
            pipeline.AddLast("enc-handshake-handler", handshakeHandler);

            channel.CloseCompletion.ContinueWith(x =>
            {
                if (_logger.IsTrace)
                {
                    _logger.Trace($"|NetworkTrace| {session} channel disconnected");
                }
                session.Disconnect(DisconnectReason.ClientQuitting, DisconnectType.Remote, "channel disconnected");
            });
        }
Ejemplo n.º 3
0
        private async Task OnMessageAsync(BrokeredMessage message)
        {
            try
            {
                Trace.WriteLine($"Processing: { message.SequenceNumber }, Label: { message.Label }...");

                string sessionId = $"{ message.Properties["SessionId"] }"; // message.SessionId
                string userId    = $"{ message.Properties["UserId"] }";

                SessionFound sessionFound = await SalesOrderActorSystem.SessionRouterActor.Ask <SessionFound>(new FindSession(sessionId), TimeSpan.FromSeconds(20));

                if (sessionFound.SessionActor.IsNobody())
                {
                    SessionCreated sessionCreated = await SalesOrderActorSystem.SessionRouterActor.Ask <SessionCreated>(new CreateSession(sessionId, userId), TimeSpan.FromSeconds(20));
                }

                // SessionCreated sessionCreated = await SalesOrderActorSystem.SessionRouterActor.Ask<SessionCreated>(new CreateSession(sessionId, userId), TimeSpan.FromSeconds(20));
            }
            catch (Exception exception)
            {
                Trace.WriteLine(exception);
            }
        }
Ejemplo n.º 4
0
        private void RegisterSession(IAudioSession session)
        {
            if (!_visibleSystemSounds && session.IsSystemSound)
            {
                session.Dispose();
                return;
            }

            var audioSession = session as AudioSession;
            var fileName     = audioSession.Process.GetMainModuleFileName(); // QUESTION: Should we use session.GroupingParam instead?

            // If we are able to grab the fileName for the process, group it with sessions from the same fileName
            if (!string.IsNullOrEmpty(fileName))
            {
                var groupID = fileName.GetHashCode();

                AudioSessionGroup sessionGroup;
                if (_sessions.TryGetValue(groupID, out var group))
                {
                    // We have a previously constrcuted group, so just add this session to that group and early out.
                    sessionGroup = group as AudioSessionGroup;
                    sessionGroup.AddSession(session);
                    return;
                }

                // Need to create a new group for this session and register it
                sessionGroup = new AudioSessionGroup(groupID, session.DisplayName);
                sessionGroup.AddSession(session);
                session = sessionGroup;
            }

            _sessions.Add(session.ID, session);
            session.SessionEnded  += OnSessionEnded;
            session.VolumeChanged += OnSessionVolumeChanged;

            SessionCreated?.Invoke(session);
        }
Ejemplo n.º 5
0
 public void TriggerSessionCreated(IP2PSession session)
 {
     SessionCreated?.Invoke(this, new SessionEventArgs(session));
 }
 private void OnSessionCreated(SessionCreatedEventArgs e)
 {
     SessionCreated?.Invoke(this, e);
 }
 public static void InvokeEvents(object sender, MushraTestDetailsModel e)
 {
     DisplaySession?.Invoke(sender, e);
     SessionCreated?.Invoke(sender, e);
     _sessionCreatedFlag = true;
 }
Ejemplo n.º 8
0
 public void Apply(SessionCreated sessionCreated)
 {
     SessionCount++;
 }
Ejemplo n.º 9
0
 private void RaiseSessionCreated(IWampClient client)
 {
     SessionCreated?.Invoke(this, new WampSessionEventArgs(client.SessionId));
 }
Ejemplo n.º 10
0
 internal static void NotifySessionCreating(object fileName, EventArgs e)
 {
     SessionCreated?.Invoke(fileName);
 }
Ejemplo n.º 11
0
 public int OnSessionCreated(IntPtr newSession)
 {
     SessionCreated?.Invoke(this, new SessionCreatedNotificationEventArgs(newSession));
     return(0);
 }
Ejemplo n.º 12
0
 public void SessionCreated(SessionCreated sessionCreated)
 {
     hubContext.Clients.Client(sessionCreated.SessionId).sessionCreated();
 }
Ejemplo n.º 13
0
        private void NotifySessionCreated(VaspSession session)
        {
            var @event = new SessionCreatedEvent(session.SessionId);

            SessionCreated?.Invoke(@event);
        }
Ejemplo n.º 14
0
 public void Handle(SessionCreated domainEvent)
 {
     _mailGateway
     .GetMailerWith("Session created", GetEmailBody(domainEvent, domainEvent.PresentationId))
     .SendTo(_repository.Find <UserProfile>().AdminEmails());
 }
Ejemplo n.º 15
0
 protected virtual void RaiseSessionCreated(WampSessionCreatedEventArgs e)
 {
     SessionCreated?.Invoke(this, e);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Raises the SessionCreated Event.
 /// </summary>
 /// <param name="args">The event data.</param>
 protected internal virtual void OnSessionCreated(SessionEventArgs args)
 {
     SessionCreated?.Invoke(this, args);
 }
Ejemplo n.º 17
0
 public void Apply(SessionCreated @event)
 {
     State = AccountState.WithSession;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Called whenever the <see cref="Session"/> has been created.
 /// </summary>
 /// <remarks>
 /// The <see cref="Session"/> can be created by calling <see cref="CreateSessionAsync"/>.
 /// </remarks>
 protected virtual void OnSessionCreated()
 {
     SessionCreated?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 19
0
        /*
         * private void CreateSalesOrder(CreateSalesOrder createSalesOrder)
         * {
         *  IActorRef sessionActor = Context.ActorSelection(SalesOrderActorRefs.SessionCollection).ResolveOne(TimeSpan.FromSeconds(10)).Result;
         *
         *  sessionActor.Tell(createSalesOrder);
         * }
         *
         * private void DestroySalesOrder(DestroySalesOrder destroySalesOrder)
         * {
         *  IActorRef sessionActor = Context.ActorSelection(SalesOrderActorRefs.SessionCollection).ResolveOne(TimeSpan.FromSeconds(10)).Result;
         *
         *  sessionActor.Tell(destroySalesOrder);
         * }
         *
         * private void AddSalesOrderLine(AddSalesOrderLine addSalesOrderLine)
         * {
         *  IActorRef sessionActor = Context.ActorSelection(SalesOrderActorRefs.SessionCollection).ResolveOne(TimeSpan.FromSeconds(10)).Result;
         *
         *  sessionActor.Tell(addSalesOrderLine);
         * }
         *
         * private void RemoveSalesOrderLine(RemoveSalesOrderLine removeSalesOrderLine)
         * {
         *  IActorRef sessionActor = Context.ActorSelection(SalesOrderActorRefs.SessionCollection).ResolveOne(TimeSpan.FromSeconds(10)).Result;
         *
         *  sessionActor.Tell(removeSalesOrderLine);
         * }
         */

        public void SessionCreated(SessionCreated sessionCreated)
        {
            SalesOrderEventSource.SessionCreated(sessionCreated);
        }