コード例 #1
0
        /// <summary>
        ///     Create TCP session factory method
        /// </summary>
        /// <returns>TCP session</returns>
        protected virtual WsSession CreateSession()
        {
            var newSession = new WsSession(this);

            if (OnSessionError != null)
            {
                newSession.OnSessionError += OnSessionError;
            }

            if (OnMessageSent != null)
            {
                newSession.OnMessageSent += OnMessageSent;
            }

            if (OnMessageReceived != null)
            {
                newSession.OnMessageReceived += OnMessageReceived;
            }

            if (OnEmptyMessage != null)
            {
                newSession.OnEmptyMessage += OnEmptyMessage;
            }

            return(newSession);
        }
コード例 #2
0
 internal void OnDisconnectedInternal(WsSession session)
 {
     OnDisconnected(session);
 }
コード例 #3
0
 /// <summary>
 ///     Handle session disconnected notification
 /// </summary>
 /// <param name="session">Disconnected session</param>
 protected virtual void OnDisconnected(WsSession session)
 {
     OnSessionDisconnected?.Invoke(session, new ConnectionEventArgs(session.Id));
 }
コード例 #4
0
 /// <summary>
 ///     Register a new session
 /// </summary>
 /// <param name="session">Session to register</param>
 internal void RegisterSession(WsSession session)
 {
     // Register a new session
     Sessions.TryAdd(session.Id, session);
 }