private void OnSessionConnected(NetworkConnection connection)
        {
            this.IsServerConnected = true;
            LogWriteLine("Server connected.");

            SessionConnected?.Invoke(connection);
        }
        internal FtpFileTransferer(FtpDirectory transferStarter, string localFile, string remoteFile, long totalBytes, TransferDirection dir)
        {
            m_transferStarter = transferStarter;
            m_transferDirection = dir;
            m_session = transferStarter.FtpSession;
            m_localFile = localFile;
            m_remoteFile = remoteFile;
            m_totalBytes = totalBytes;

            if (dir == TransferDirection.Upload)
            {
                m_beginEvent = new FileEventDelegate(m_session.Host.RaiseBeginPutFileEvent);
                m_endEvent = new FileEventDelegate(m_session.Host.RaiseEndPutFile);
                m_streamCopyRoutine = new StreamCopyDelegate(LocalToRemote);
                m_ftpFileCommandRoutine = new FtpDelegate(m_session.ControlChannel.STOR);
                m_localFileOpenMode = FileMode.Open;
            }
            else
            {
                m_beginEvent = new FileEventDelegate(m_session.Host.RaiseBeginGetFileEvent);
                m_endEvent = new FileEventDelegate(m_session.Host.RaiseEndGetFile);
                m_streamCopyRoutine = new StreamCopyDelegate(RemoteToLocal);
                m_ftpFileCommandRoutine = new FtpDelegate(m_session.ControlChannel.RETR);
                m_localFileOpenMode = FileMode.Create;
            }
        }
Example #3
0
        public async void StartHost()
        {
            if (Main == null)
            {
                throw new InvalidOperationException(" 'Main' was null!");
            }

            server.Start();

            while (true)
            {
                var socket = await server.AcceptSocketAsync();

                var session = new TelnetSession(this, socket);
                _sessions.Add(session.ConnectionId, session);

                var e = new SessionEventArgs(session);  //todo: this client event can block the whole server
                SessionConnected?.Invoke(this, e);

                if (!e.RefuseConnection)
                {
                    session.Run();
                }
                else
                {
                    session.Kick();
                }
            }
        }
 internal FtpDataStream(ControlChannel ctrl, TcpClient client)
 {
     m_session = ctrl.Session;
     m_ctrl = ctrl;
     m_tcpClient = client;
     m_stream = client.GetStream();
     m_session.BeginDataTransfer(this);
 }
Example #5
0
 internal static void RaiseSessionConnectedEvent([NotNull] Player player)
 {
     if (player == null)
     {
         throw new ArgumentNullException(nameof(player));
     }
     SessionConnected?.Invoke(null, new PlayerEventArgs(player));
 }
 internal FtpDirectory(SessionConnected s, string parentPath, string name)
 {
     m_session = s;
     if (name != "")
     {
         m_name = name;
         m_fullPath = parentPath + m_name + "/";
     }
     else
         m_name = m_fullPath = "/";
 }
Example #7
0
        /// <summary>
        /// Called on logon to the FIX session.
        /// </summary>
        /// <param name="sessionId">The session identifier.</param>
        public void OnLogon(SessionID sessionId)
        {
            var connected = new SessionConnected(
                this.Brokerage,
                sessionId.ToString(),
                this.guidFactory.Generate(),
                this.clock.TimeNow());

            this.messagingAdapter.SendToBus(connected, null, this.clock.TimeNow());
            this.Logger.LogDebug(LogId.Network, $"Connected to session {sessionId}");
        }
        internal FtpDirectory(SessionConnected s)
        {
            m_session = s;

            m_fullPath = s.ControlChannel.PWD();
            if (m_fullPath == "/")
            {
                m_name = m_fullPath;
                return;
            }

            string[] directories = m_fullPath.Split('/');
            m_name = directories[directories.Length - 1];
            m_fullPath += "/";
        }
Example #9
0
        private void OnMessage(SessionConnected message)
        {
            this.Logger.LogInformation(LogId.Network, $"Connected to session {message.SessionId}.");

            this.OnConnected();
        }
 /// <summary>
 /// Raise the <see cref="SessionConnected"/> event.
 /// </summary>
 /// <param name="session">The new session.</param>
 protected void InvokeSessionConnected(IEtpSession session)
 {
     SessionConnected?.Invoke(this, session);
 }
 private void OnConnected()
 {
     SessionConnected?.RaiseEventSafe(this, nameof(SessionDisconnected));
 }