www.pudn.com > Example_BluetoothChat.rar > BluetoothClient.h


#ifndef __BLUETOOTHCLIENT_H__ 
#define __BLUETOOTHCLIENT_H__ 
 
// System Includes 
#include  
 
// User defined includes 
#include "BluetoothDefinitions.h" // KMaxMessageLength 
 
// Forward Declaration 
class MBluetoothObserver; 
 
// CLASS DECLARATION 
 
/** 
* 
* This is the Bluetooth Client and handles setting up sockets for Bluetooth communications 
* 
* It requires an observer to handle UI feedback on certain events 
* 
*/ 
/** 
* 
* @class	CBluetoothClient BluetoothClient.h  
* @brief	This is the Bluetooth Client and handles setting up sockets for Bluetooth communications 
* 
* It requires an observer to handle UI feedback on certain events 
* 
* Copyright (c) EMCC Software Ltd 2003 
* @version	1.0 
*  
*/ 
class CBluetoothClient : public CActive 
	{ 
	public: // Constructors 
		static CBluetoothClient* 	NewL(MBluetoothObserver& aObserver); 
		~CBluetoothClient(); 
 
	private: // Constructors - Symbian 2nd stage 
		CBluetoothClient(MBluetoothObserver& aObserver); 
		void 				ConstructL(); 
 
	public: // Member functions 
		void 				ConnectToServerL(const TBTDevAddr& aBTDevAddr, const TInt aPort); 
		void 				Send(const TDesC& aMessage); 
		TBool 				IsConnected(); 
		TBool 				AvailableToSend(); 
 
	public:	// Member functions from CActive 
		void 				RunL(); 
		void 				DoCancel(); 
 
	private: // member functions, utility functions 
		void 				Disconnect(); 
		void 				RequestData(); 
		void 				SendL(const TDesC& aMessage); 
 
	private: // Private member data 
		RSocketServ										iSocketServer; 
		RSocket											iSendingSocket; 
		TBTSockAddr										iSocketAddress; 
		TBuf8	iMessage; 
		TSockXfrLength 									iLen; 
		MBluetoothObserver&								iObserver; 
 
	private: // State machine definition 
		enum TState  
			{ 
			EDisconnected, 
			EConnecting, 
			EConnected, 
			EWaitingForMessage, 
			ESendData 
			}; 
	 
		TState				iState; 
	}; 
 
#endif // __BLUETOOTHCLIENT_H__