Exemple #1
0
        private async Task DoStartSessionAsync(TcpClient client)
        {
            var session = new SmsServerSession(this, this.MessageFactory);

            session.NetworkMessageReceived += OnSessionNetworkMessageReceived;
            session.SessionEnded           += OnSessionEnded;
            await session.StartAsync(client);

            var sessions = this.Sessions;

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

            this.OnSessionStarted(session);
        }
Exemple #2
0
        private async Task DoStopSessionAsync(SmsServerSession session)
        {
            if (session != null)
            {
                bool found    = false;
                var  sessions = this.Sessions;
                lock (sessions)
                {
                    if (sessions.Remove(session))
                    {
                        session.NetworkMessageReceived -= OnSessionNetworkMessageReceived;
                        session.SessionEnded           -= OnSessionEnded;
                        found = true;
                    }
                }

                if (found)
                {
                    await session.StopAsync();
                }

                this.OnSessionStopped(session);
            }
        }
Exemple #3
0
 protected virtual async Task DoNetworkMessageReceived(SmsServerSession session, NetworkMessage message)
 {
     await Task.Delay(0);
 }
Exemple #4
0
 protected virtual void OnSessionStopped(SmsServerSession session)
 {
 }