Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals

serversession.h

Go to the documentation of this file.
00001 /*
00002  * serversession.h,v 1.29 2004/01/06 17:05:41 mattid Exp
00003  *
00004  * COBAIN - Communications API for EPOC Environments
00005  * Copyright (C) 2002-2003 Matti Dahlbom, Matti Kokkola
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * Contact: Matti Dahlbom <matti@777-team.org>
00022  *          Matti Kokkola <matti.kokkola@iki.fi>
00023  */
00024 
00025 #ifndef __SERVERSESSION_H
00026 #define __SERVERSESSION_H
00027 
00028 #include <e32svr.h>
00029 
00030 #include "cobainserver.h"
00031 #include "bluetoothcommunicator.h"
00032 
00033 // panic category and error codes
00034 _LIT(KSessionPanic, "Server Session");
00035 
00036 const TInt KErrSessionBase = -14040;
00037 const TInt KErrSessionBadSocketTableIndex = KErrSessionBase - 2;
00038 const TInt KErrSessionTryingToAllocListeningCon = KErrSessionBase - 3;
00039 const TInt KErrSessionTryingToDeallocListeningCon = KErrSessionBase - 4;
00040 const TInt KErrSessionConnectionNotFoundInGet = KErrSessionBase - 5;
00041 //const TInt KErrSessionConnectionNotFoundInDealloc = KErrSessionBase - 6;
00042 
00043 // How many open sockets there can be per client thread
00044 // (i.e. per server session)
00045 const TInt KMaxSocketCount = 8;
00046 
00047 // forward declarations
00048 class CConcreteConnection;
00049 //class CReceiveSession;
00050 
00051 typedef TSglQue<CConcreteConnection> ConnectionQueue;
00052 
00059 class CServerSession : public CSession 
00060 {
00061     public:
00062         static CServerSession* NewL(RThread& aClient, 
00063                                     CCobainServer* aServer);
00064     
00065         void ServiceL(const RMessage& aMessage);
00066 
00067         void SetPeerList(TPeerDataList *aPeerList);
00068 
00069         static void PanicClient(const RMessage& aMessage, 
00070                                 CCobainServer::TServerPanic aPanic);
00071 
00072         // connection management
00073         void DeallocateConnection(CConcreteConnection *aConnection);
00074         TInt AllocateConnection(CConcreteConnection *aConnection);
00075         CConcreteConnection* GetConnection(TInt id);
00076         
00077     private:
00078         CServerSession(RThread& aClient, CCobainServer* aServer/*,
00079                        CObjectCon* aSubsessionContainer*/);
00080         void ConstructL();
00081         ~CServerSession();
00082 
00083         // ServiceL() handlers
00084         void GetNumPeersL(const RMessage& aMessage);
00085         void GetPeer(const RMessage& aMessage);
00086         void Send(const RMessage &aMessage);
00087         void Receive(const RMessage& aMessage);
00088         void CancelReceive(const RMessage &aMessage);
00089         void StartListen(const RMessage& aMessage);
00090         void AbortListen(const RMessage& aMessage);
00091         void GetIncomingConnection(const RMessage& aMessage);
00092         void ConnectL(const RMessage &aMessage);
00093         void CloseSocket(const RMessage &aMessage);
00094 
00095         // Array for concrete sockets
00096         CConcreteConnection *iConnections[KMaxSocketCount];
00097 
00098         CBTCommunicator *iBTCommunicator;
00099 
00100         TPeerDataList *iPeerList;
00101         CCobainServer* iServer;
00102 
00103         // listening connection
00104         CConcreteConnection *iListeningConnection; // not owned resource
00105 };
00106 
00107 #endif

Generated on Tue Jan 13 15:47:07 2004 for CobainAPIImplementation by doxygen 1.3.5