|
1 // Server.h |
|
2 // |
|
3 // Copyright (c) 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #if !defined(AFX_SERVER_H__ECF36F93_36B9_491D_A482_5A1FCBE29932__INCLUDED_) |
|
14 #define AFX_SERVER_H__ECF36F93_36B9_491D_A482_5A1FCBE29932__INCLUDED_ |
|
15 |
|
16 #if _MSC_VER > 1000 |
|
17 #pragma once |
|
18 #endif // _MSC_VER > 1000 |
|
19 |
|
20 #include "Base.h" |
|
21 #include "ServerSocket.h" |
|
22 #include "SocketCommandHandler.h" |
|
23 #include "Preferences.h" |
|
24 #include "ConsoleWindow.h" |
|
25 |
|
26 |
|
27 class CConsoleWindow; |
|
28 |
|
29 |
|
30 class CServer : public CBase, public MSocketClientAcceptor, public MSocketClosureObserver, public MSocketCommandHandler, public MWindowObserver |
|
31 { |
|
32 public: |
|
33 static CServer* New(HINSTANCE aAppHandle); |
|
34 virtual ~CServer(); |
|
35 void HandleException(TException aException); |
|
36 TPreferences& Preferences(); |
|
37 const TPreferences& Preferences() const; |
|
38 void Listen(); |
|
39 private: |
|
40 CServer(HINSTANCE aAppHandle); |
|
41 void Construct(); |
|
42 private: // From MClientAcceptor. |
|
43 virtual void HandleNewClient(CClientSocket& aClientSocket); |
|
44 private: // From MSocketClosureObserver. |
|
45 virtual void HandleSocketClosure(CSocket& aSocket); |
|
46 private: // From MSocketCommandHandler. |
|
47 virtual void HandleSocketCommand(TPacketHeader::TPacketType aCommand, const char* aPacket, int aPacketLength, CSocketCommandReader& aReader); |
|
48 virtual void HandleSocketClosure(CSocketCommandReader& aReader); |
|
49 private: // From MWindowObserver. |
|
50 virtual void HandleWindowClosure(CWindow& aWindow); |
|
51 virtual LRESULT HandleWindowCommand(UINT aMessage, WPARAM aWParam, LPARAM aLParam); |
|
52 private: |
|
53 HINSTANCE iAppHandle; |
|
54 CServerSocket* iSocket; |
|
55 CConsoleWindow* iConsole; |
|
56 TPreferences iPreferences; |
|
57 unsigned short iPort; |
|
58 }; |
|
59 |
|
60 #endif // !defined(AFX_SERVER_H__ECF36F93_36B9_491D_A482_5A1FCBE29932__INCLUDED_) |