fCraft.Session.Start C# (CSharp) Method

Start() public method

public Start ( ) : void
return void
        public void Start() {
            try {
                IP = ((IPEndPoint)(client.Client.RemoteEndPoint)).Address;
                if( Server.RaiseSessionConnectingEvent( IP ) ) return;

                reader = new BinaryReader( client.GetStream() );
                writer = new PacketWriter( client.GetStream() );

                Logger.Log( "Session.Start: Incoming connection from {0}", LogType.Debug,
                            IP );

                ioThread = new Thread( IoLoop ) {
                    Name = "fCraft.Session",
                    IsBackground = true
                };
                ioThread.Start();
            } catch( Exception ex ) {
                Logger.LogAndReportCrash( "Session failed to start", "fCraft", ex, false );
                Disconnect();
            }
        }

Usage Example

Example #1
0
 static void CheckConnections( SchedulerTask param ) {
     TcpListener listenerCache = listener;
     if( listenerCache != null && listenerCache.Pending() ) {
         try {
             Session newSession = new Session( listenerCache.AcceptTcpClient() );
             newSession.Start();
         } catch( Exception ex ) {
             Logger.Log( "Server.CheckConnections: Could not accept incoming connection: " + ex, LogType.Error );
         }
     }
 }