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

📄 messageclient.h

📁 Symbian下的p2p工程
💻 H
字号:
/* Copyright (c) 2004, Nokia. All rights reserved */


#ifndef __MESSAGECLIENT_H__
#define __MESSAGECLIENT_H__

#include <e32base.h>
#include <es_sock.h>
#include <bt_sock.h>
#include <BTextNotifiers.h>
#include <BtSdp.h>

// FORWARD DECLARATIONS
class CMessageServiceSearcher;
class MLog;

/**
* CMessageClient
* Connects and sends messages to a remote machine using bluetooth
*/
class CMessageClient : public CActive
    {
    public: // Constructors and destructor

        /**
        * NewL()
        * Construct a CMessageClient
        * @param aLog the log to send output to
        * @return a pointer to the created instance of CMessageClient
        */
        static CMessageClient* NewL( MLog& aLog );

        /**
        * NewLC()
        * Construct a CMessageClient
        * @param aLog the log to send output to
        * @return a pointer to the created instance of CMessageClient
        */
        static CMessageClient* NewLC( MLog& aLog );

        /**
        * ~CMessageClient()
        * Destroy the object and release all memory objects. 
        * Close any open sockets.
        */
        virtual ~CMessageClient();

    public:     // New functions

        /**
        * IsConnected()
        * @return ETrue if the client is fully connected to the server.
        */
        TBool IsConnected();

        /**
        * IsConnecting()
        * @return ETrue if the client is establishing a 
        * connection to the server.
        */
        TBool IsConnecting();

        /**
        * IsConnected()
        * @return ETrue if the client is connected.
        */
        TBool IsSendingMessage();


        /**
        * IsReadyToSendMessage()
        * @return ETrue if the client can send a message.
        */
        TBool IsReadyToSendMessage();

        /**
        * ConnectL()
        * Connect to an available service on a remote machine
        */
        void ConnectL();

        /** 
        * DisconnectL()
        * Disconnect from remote machine
        */
        void DisconnectL();

        /**
        * SendMessageL()
        * Sends a message to a service on a remote machine.
        */    
        void SendMessageL();

    protected:    // from CActive

        /**
        * DoCancel()
        * Cancel any outstanding requests
        */
        void DoCancel();

        /**
        * RunL()
        * Respond to an event
        */
        void RunL();

    private:    // Functions from base classes
    
        /**
        * ConnectToServerL
        * Connects to the service
        */    
        void ConnectToServerL();

        /**
        * DisonnectFromServerL()
        * Disconnects from the service
        */    
        void DisconnectFromServerL();

        /** 
        * WaitOnConnectionL()
        * Wait for data or disconnection
        */
        void WaitOnConnectionL();

        /**
        * CMessageClient()
        * Constructs this object
        */
        CMessageClient( MLog& aLog );

        /**
        * ConstructL()
        * Performs second phase construction of this object
        */
        void ConstructL();

    private:    // data

        /**
        * TState
        * The state of the active object, determines behaviour within
        * the RunL method.
        * EWaitingToGetDevice waiting for the user to select a device
        * EGettingDevice searching for a device
        * EGettingService searching for a service
        * EGettingConnection connecting to a service on a remote machine
        * EConnected connected to a service on a remote machine
        * ESendingMessage sending a message to the remote machine
        */
        enum TState 
            {
                EWaitingToGetDevice,
                EGettingDevice,
                EGettingService,
                EGettingConnection,
                EConnected,
                ESendingMessage,
                EDisconnecting
            };

        /** iState the current state of the client */
        TState iState;

        /** 
        * iServiceSearcher searches for service this 
        * client can connect to.
        * Owned by CMessageClient
        */
        CMessageServiceSearcher* iServiceSearcher;

        /** iLog the log to send output to */
        MLog& iLog;

        /** 
        * iMessage a copy of the message to send 
        * Owned by CMessageClient
        */
        HBufC8* iMessage;

        /** iSocketServer a connection to the socket server */
        RSocketServ iSocketServer;

        /** iSendingSocket a socket to connect with */
        RSocket iSendingSocket;

        /** iServiceClass the service class UUID to search for */
        TUUID iServiceClass;

        /** iDummyBuffer buffer needed for read on connection to server */
        TBuf8 <1>  iDummyBuffer;

    };

#endif // __MESSAGECLIENT_H__

// End of File

⌨️ 快捷键说明

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