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

📄 bluetoothsockconnector.cpp

📁 基于symbian UIQ 的一款古老的飞机游戏。对入门学习很有帮助。
💻 CPP
字号:
/*============================================================================ Name			: BlueToothConnector.cpp Author	  		:  Copyright   	: Description 	: Implementation============================================================================*/// INCLUDE FILES#include "BluetoothSockConnector.h"#include "common.hrh"/*============================================================================CBluetoothSockConnector's two stage constructor============================================================================*/CBluetoothSockConnector* CBluetoothSockConnector::NewL(RSocket& aBtSocket, MSocketConnectorObserver& aSockConnObs, RSocketServ& aSocketServer)	{    CBluetoothSockConnector* self = new (ELeave) CBluetoothSockConnector(aBtSocket, aSockConnObs, aSocketServer);    CleanupStack::PushL(self);    self->ConstructL();    CleanupStack::Pop();    return self;	}/*============================================================================CBluetoothSockConnector's costructor============================================================================*/CBluetoothSockConnector::CBluetoothSockConnector(RSocket& aBtSocket, MSocketConnectorObserver& aSockConnObs, RSocketServ& aSocketServer)	:CActive(CActive::EPriorityStandard), iBtSocket(aBtSocket), iSockConnObs(aSockConnObs), iSocketServer(aSocketServer)	{	CActiveScheduler::Add(this);	}/*============================================================================CBluetoothSockConnector's second phase constructor ============================================================================*/void CBluetoothSockConnector::ConstructL()	{		/*	============================================================================	Using the Socket Server we need to load the RFCOMM communication protocol.	First of all we need to see if BT RFCOMM is supported.	============================================================================	*/	TProtocolDesc pdesc;	User::LeaveIfError(iSocketServer.FindProtocol(KBTRFCOMM(), pdesc));	/*	============================================================================	Open the socket using BT RFCOMM	============================================================================	*/	User::LeaveIfError(iBtSocket.Open(iSocketServer, KBTRFCOMM));	}/*============================================================================CBluetoothSockConnector's destructor============================================================================*/CBluetoothSockConnector::~CBluetoothSockConnector()	{	Cancel();	}/*============================================================================DoCancel is called as part of the active object's Cancel().Outstanding operations for a BT socket include: read, write, Ioctl, connect,accept, shutdown and the Baseband event notifier. All of these operations willbe completed by this call============================================================================*/void CBluetoothSockConnector::DoCancel()	{	iBtSocket.CancelAll();	}/*============================================================================Handles the active object's socket connection completion event ============================================================================*/void CBluetoothSockConnector::RunL()	{	iSockConnObs.OnSockConnectionComplete(iStatus.Int());	}/*============================================================================Connect to the remote BT device on a given BT device address and on a given RFCOMM service's port============================================================================*/void CBluetoothSockConnector::ConnectToRemoteBtDeviceL(const TBTDevAddr& aDevAddr, TInt aPort)	{	/*	============================================================================	Set the remote device address and service port using TBTSockAddr	============================================================================	*/	iBtDevAddr.SetBTAddr(aDevAddr);	iBtDevAddr.SetPort(aPort);		/*	============================================================================	Connect the BT socket to the remote device.	============================================================================	*/	iBtSocket.Connect(iBtDevAddr, iStatus);	SetActive();	}	/*============================================================================Handles a leave occurring in the request completion event handler RunL().============================================================================*/TInt CBluetoothSockConnector::RunError(TInt aError)	{	iSockConnObs.OnSockConnectionComplete(aError);	return KErrNone;	}

⌨️ 快捷键说明

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