examples/SFExamples/RockPaperScissorsGameSourceCode_S60/RPS/inc/BluetoothSocketWriterReader.h

00001 /*
00002 Copyright (c) 2002-2011 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 * Redistributions in binary form must reproduce the above copyright notice,
00010   this list of conditions and the following disclaimer in the documentation
00011   and/or other materials provided with the distribution.
00012 * Neither the name of Nokia Corporation nor the names of its contributors
00013   may be used to endorse or promote products derived from this software
00014   without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 Description:  CSocketReader is an active object responsible for listening for incoming data from
00028                     a remote BT device and notifying when the data arrives along with any connection error.
00029                     
00030                     CSocketWriter is an active object responsible for sending data to a remote BT device
00031                     and notifying when the sending data is completed along with any connection error.
00032 
00033 */ 
00034  
00035 
00036 
00037 #ifndef __BLUETOOTHSOCKETWRITERREADER_H__
00038 #define __BLUETOOTHSOCKETWRITERREADER_H__
00039 
00040 // INCLUDES
00041 #include <es_sock.h>
00042 #include <in_sock.h>
00043 #include "CommonInterfaces.h"
00044 
00045 
00047 const TInt KReadBufferSize = 128;
00048 
00049 // CLASS DECLARATION
00054 class CSocketReader  : public CActive
00055         {
00056 public:
00062         CSocketReader(RSocket& aBtSocket, MSocketWriterReaderObserver& aObserver);
00063         
00067         ~CSocketReader();
00068         
00072         void ReadData();
00073         
00074 private: // from CActive
00078         void DoCancel();
00079         
00083         void RunL();
00084         
00092         virtual TInt RunError(TInt aError);
00093 
00094 private:
00098         RSocket& iBtSocket;
00099         
00103         MSocketWriterReaderObserver& iObserver;
00104         
00108     TSockXfrLength iLen;
00109     
00113         TBuf8<KReadBufferSize> iBuffer;
00114         };
00115 
00117 // CLASS DECLARATION
00122 class CSocketWriter : public CActive
00123         {
00124 public:
00130         CSocketWriter(RSocket& aBtSocket, MSocketWriterReaderObserver& aObserver);
00131         
00135         ~CSocketWriter();
00136         
00140         TInt Write(const TDesC8& aBuf);
00141         
00142 
00143 private: // from CActive
00147         void DoCancel();
00148         
00152         void RunL();
00153         
00161         virtual TInt RunError(TInt aError);
00162 
00163 private:
00167         RSocket& iBtSocket;
00168         
00172         MSocketWriterReaderObserver& iObserver;
00173         };
00174 
00175 #endif  // __BLUETOOTHSOCKETWRITERREADER_H__

Generated by  doxygen 1.6.2