Exemple #1
0
 void CompleteSession(APICommand command)
 {
     if (OnSessionEnded != null)
     {
         OnSessionEnded.Invoke(this);
     }
 }
Exemple #2
0
        private void SetUpEvents()
        {
            _hubConnection.On <CurrentSong>("startSongCommandNotification", currentSong =>
            {
                OnSongStarted?.Invoke(this, currentSong);
            });

            _hubConnection.On <CurrentSong>("finishSongCommandNotification", currentSong =>
            {
                OnSongFinished?.Invoke(this, currentSong);
            });

            _hubConnection.On <Song>("addSongCommandNotification", song =>
            {
                OnSongAdded?.Invoke(this, song);
            });

            _hubConnection.On <SongToRemove>("removeSongCommandNotification", song =>
            {
                OnRemoveSong?.Invoke(this, song);
            });

            _hubConnection.On("endSessionCommandNotification", () =>
            {
                OnSessionEnded?.Invoke(this, null);
            });

            _hubConnection.On("startSessionCommandNotification", () =>
            {
                OnRemoveSong?.Invoke(this, null);
            });
        }
Exemple #3
0
 /// <summary>
 /// Реакция на входящий поток, по умолчанию реакция - дисконнект
 /// </summary>
 /// <param name="info">Входящий поток</param>
 public virtual void OnIncomingStream(StreamInfo info)
 {
     SendObject(new APIAnswer(new APICommand("SendStream", null), null,
                              new NotImplementedException("Send stream are'nt supported by this API")));
     if (OnSessionEnded != null)
     {
         OnSessionEnded.Invoke(this);
     }
 }
Exemple #4
0
 private void RemoveSession(string id)
 {
     try
     {
         var ea = new SessionEndingEventArgs(id);
         OnSessionEnding?.Invoke(this, ea);
     }
     finally
     {
         _sessions.Remove(id, out HttpContext value);
         foreach (var topic in _topics)
         {
             topic.Value.Remove(id, out HttpContext x);
         }
         OnSessionEnded?.Invoke(this, new SessionEndedEventArgs(id));
     }
 }
Exemple #5
0
        private void Run()
        {
#if TEST_MODE
            // TODO: Remove - This is only for testing ...
            while (true)
#else
            while (Clients.Values.Count > 0)
#endif
            {
                foreach (Client client in Clients.Values)
                {
                    // client.Outbox.Enqueue("PING-Session");
                }

                Thread.Sleep(1000);
            }

            sessionThread = null;

            OnSessionEnded?.Invoke(this);

            Console.WriteLine(string.Format("Session '{0}' stopped.", Name));
        }
Exemple #6
0
 internal void SystemEvents_SessionEnded(object sender, SessionEndedEventArgs e)
 {
     OnSessionEnded?.Invoke(sender, e);
 }