Version: 0.6.0
network.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Server)
3  * Purpose: wxGISNetworkService class. Network connection main service class.
4  * It adds plug-ins of different types of network connections (TCP, Jabber etc.)
5  * Author: Bishop (aka Barishnikov Dmitriy), polimax@mail.ru
6  ******************************************************************************
7 * Copyright (C) 2008-2011 Bishop
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  ****************************************************************************/
22 #pragma once
23 
24 #include "wxgissrv/srv_framework/framework.h"
25 #include "wxgissrv/srv_networking/networking.h"
26 
27 class INetworkPlugin;
29 
34 class wxMsgOutThread : public wxThread
35 {
36 public:
38  virtual void *Entry();
39  virtual void OnExit();
40 
41 private:
42  wxGISNetworkService* m_pParent;
43 };
44 
45 
46 
50 class WXDLLIMPEXP_GIS_FRW wxGISNetworkService :
51  public IService,
52  public INetMessageReceiver
53 {
54 public:
55  wxGISNetworkService(void);
56  virtual ~wxGISNetworkService(void);
57  //IService
58  virtual bool Start(IServerApplication* pApp, wxXmlNode* pConfig);
59  virtual bool Stop(void);
60  //INetMessageReceiver
61  virtual void ProcessMessage(WXGISMSG msg, wxXmlNode* pChildNode);
62  //wxGISNetworkService
63  virtual wxString GetServerName(void);
64  virtual bool CanAcceptConnection(void);
65  virtual bool AddConnection(INetServerConnection* pNetServerConnection);
66  virtual void DelConnection(long nConnID);
67  virtual void PutInMessage(WXGISMSG msg);//message to server
68  virtual void PutOutMessage(WXGISMSG msg);//message to clients
69  virtual WXGISMSG GetOutMessage(void);
70  virtual void ProcessOutMessage(WXGISMSG msg);
71  virtual void SetAuth(AUTHRESPOND sUserInfo);
72  virtual AUTHRESPOND GetAuth(long nID);
73 protected:
74  virtual void ClearMessageQueue(void);
75 protected:
76  wxXmlNode* m_pConfig;
77  IServerApplication* m_pApp;
78  std::vector<INetworkPlugin*> m_NetworkPluginArray;
79  short m_nMaxConnectoinCount;
80  long m_nConnectionCounter, m_nConnectionID;
81  wxString m_sServerName;
82  std::map<long, INetServerConnection*> m_NetworkConnectionMap;
83  typedef std::map<long, INetServerConnection*>::iterator ConnIT;
84  wxMsgOutThread* m_pMsgOutThread;
85  wxCriticalSection m_CriticalSection;
86  WXGISMSGQUEUE m_MsgQueue;
87 };
88 
92 class INetworkPlugin
93 {
94 public:
95  virtual ~INetworkPlugin(void){};
96  virtual bool Start(wxGISNetworkService* pNetService, wxXmlNode* pConfig) = 0;
97  virtual bool Stop(void) = 0;
98 };
The network server connection interface class.
Definition: netconn.h:26
A Server side INetworkPlugin interface.
Definition: networkplugin.h:30
A Server output message thread.
Definition: network.h:34
A Server side Network Service.
Definition: servernet.h:49