hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CUDPSender.h
branchRCL_3
changeset 59 8ad140f3dd41
parent 0 a03f92240627
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  UDP packet sender
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CUDPSENDER_H
       
    21 #define CUDPSENDER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <in_sock.h>
       
    26 
       
    27 // CONSTANTS
       
    28 const TInt KWriteBufferSize = 128;
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class MUDPSenderObserver;
       
    32 class CDesC8Array;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37 *  Socket writer. Asynchronously writes data to opened socket.
       
    38 */
       
    39 NONSHARABLE_CLASS( CUDPSender ) : public CActive
       
    40     {
       
    41     public:  // Constructors and destructor
       
    42 
       
    43         /**
       
    44         * Factory function.
       
    45         * @param aObserver Pointer to observer.
       
    46         * @return New CUDPSender instance.
       
    47         */
       
    48         static CUDPSender* NewL( MUDPSenderObserver* aObserver );
       
    49 
       
    50         /**
       
    51         * Factory function.
       
    52         * @param aObserver Pointer to observer.
       
    53         * @return New CUDPSender instance.
       
    54         */
       
    55         static CUDPSender* NewLC( MUDPSenderObserver* aObserver );
       
    56 
       
    57         /**
       
    58         * Destructor.
       
    59         */
       
    60         ~CUDPSender();
       
    61 
       
    62     public: // New functions
       
    63 
       
    64         /**
       
    65         * Issues writing data to UDP socket. If the request is already
       
    66         * pending the data will be written to queue and it will be
       
    67         * handled afterwards.
       
    68         * @param aPort Port to write to.
       
    69         * @param aData Data to be written.
       
    70         */
       
    71         void IssueWriteL( TUint aPort, const TDesC8& aData );
       
    72 
       
    73         /**
       
    74         * Resets transfer buffer.
       
    75         */
       
    76         void ResetTransferBuffer();
       
    77 
       
    78         /**
       
    79         * Continues writing if there is something in the buffer left.
       
    80         */
       
    81         void ContinueAfterError();
       
    82 
       
    83     private:
       
    84         /**
       
    85         * Writes one descriptor from queue.
       
    86         */
       
    87         void IssueWrite();
       
    88 
       
    89     protected: // Functions from base classes
       
    90 
       
    91         /**
       
    92         * From CActive. Pending request has been completed.
       
    93         */
       
    94         void RunL();
       
    95 
       
    96         /**
       
    97         * From CActive. Pending request has been cancelled.
       
    98         */
       
    99         void DoCancel();
       
   100 
       
   101         /**
       
   102         * From CActive. RunL has leaved.
       
   103         */
       
   104         TInt RunError( TInt aError );
       
   105 
       
   106 
       
   107     private:
       
   108 
       
   109         /**
       
   110         * Default constructor.
       
   111         * @param aObserver Pointer to observer.
       
   112         */
       
   113         CUDPSender( MUDPSenderObserver* aObserver );
       
   114 
       
   115         /**
       
   116         * 2nd phase constructor.
       
   117         */
       
   118         void ConstructL();
       
   119 
       
   120     private:    // Data
       
   121         RSocketServ iSocketServ;
       
   122         CDesC8Array* iTransferBufferArray;
       
   123         MUDPSenderObserver* iObserver;
       
   124         RSocket iSocket;
       
   125         TBuf8<KWriteBufferSize> iWriteBuffer;
       
   126         RTimer iTimer;
       
   127         TBool iWaiting;
       
   128         TInetAddr iRemoteAddr;
       
   129     };
       
   130 
       
   131 #endif      // CUDPSender_H
       
   132 
       
   133 // End of File