⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tmsession.h

📁 c++下s60终端对终端传输协议
💻 H
字号:
/* Copyright (c) 2005, Forum Nokia. All rights reserved */


#ifndef __TMSESSION_H__
#define __TMSESSION_H__

// INCLUDE FILES
#include <e32base.h>
#include <f32file.h>
#include "TmServer.h"
#include "ClientServerCommon.h"

// FORWARD DECLARATIONS
class CTmServer;

/**
* The filenames used in this example
*/
_LIT(KAddressFileName, "address.dat");
_LIT(KPortFileName, "port.dat");
_LIT(KTypeFileName, "type.dat");

// CLASS DECLARATION
/**
* CTmServerSession.
*  An instance of class CTmServerSession is created for each client.
*/
class CTmServerSession : public CSession2  // CSession
    {
    public: // Constructors and destructors

        /**
        * NewL.
        * Two-phased constructor.
        * @param aClient The Client's thread.
        * @param aServer The server.
        * @return Pointer to created CTmServerSession object.
        */
        static CTmServerSession* NewL( CTmServer& aServer );

        /**
        * NewLC.
        * Two-phased constructor.
        * @param aClient The Client's thread.
        * @param aServer The server.
        * @return Pointer to created CTmServerSession object.
        */
        static CTmServerSession* NewLC( CTmServer& aServer );

        /**
        * ~CTmServerSession.
        * Destructor.
        */
        virtual ~CTmServerSession();

    public: // Functions from base classes

        /**
        * From CSession, ServiceL.
        * Service request from client.
        * @param aMessage Message from client
        *                 (containing requested operation and any data).
        */
        void ServiceL( const RMessage2& aMessage );

    private: // Constructors and destructors

        /**
        * CTmServerSession.
        * C++ default constructor.
        * @param aClient The Client's thread.
        * @param aServer The server.
        */
        CTmServerSession( CTmServer& aServer );

        /**
        * ConstructL.
        * 2nd phase constructor.
        */
        void ConstructL();

    private: // New methods

        /**
        * PanicClient.
        * Causes the client thread to panic.
        * @param aPanic Panic code.
        */
        void PanicClient( TInt aPanic ) const;

        /**
        * SetAddressL.
        * Saves the remote server address given by the client of this session.
        */
        void SetAddressL();

        /**
        * RequestAddressL.
        * Writes the remote server address that was set using SetAddressL back 
        * to the client.
        */
        void RequestAddressL();

        /**
        * SetPortL.
        * Saves the remote server port given by the client of this session.
        */
        void SetPortL();

        /**
        * RequestPortL.
        * Writes the remote server port that was set using SetPortL back to the
        * client.
        */
        void RequestPortL();

        /**
        * SetTypeL.
        * Saves the remote server type given by the client of this session.
        */
        void SetTypeL();

        /**
        * RequestTypeL.
        * Writes the remote server type that was set using SetTypeL back to the
        * client.
        */
        void RequestTypeL();
        
        /**
        * RequestAllL.
        * Writes the remote server address, port and type that wer set 
        * using (one or more of) the setter methods back to the client.
        */
        void RequestAllL();
        
        /**
        * SetAllL.
        * Saves the remote server addres, port and type given by the client 
        * of this session.
        */
        void SetAllL();

        /**
        * Two utility methods for writing and reading the encrypted files.
        */
        void WriteFileL( TInt aMsgIndex, const TDesC& aFileName );
        void ReadFileL( TInt aMsgIndex, const TDesC& aFileName );

    private: // Data

        /**
        * iServer, reference to the server.
        */
        CTmServer& iServer;
        
        /**
        * iFs, reference to the file server used by this session
        */
        RFs iFs;
        
        /**
         * iClientMsg, reference to the message received from the client
         */
        RMessage2 iClientMsg;
    };

#endif // __TMSESSION_H__


// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -