Version: 0.6.0
servernet.h
1 /******************************************************************************
2  * Project: wxGIS
3  * Purpose: network server class.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2008-2010,2014 Dmitry Baryshnikov
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  ****************************************************************************/
21 #pragma once
22 
23 #include "wxgis/net/netconn.h"
24 #include "wxgis/net/netevent.h"
25 
32 class WXDLLIMPEXP_GIS_NET INetPlugin : public wxEvtHandler
33 {
34  DECLARE_ABSTRACT_CLASS(INetPlugin)
35 public:
36  virtual ~INetPlugin(void);
37  virtual bool Start(INetService* pNetService, const wxXmlNode* pConfig) = 0;
38  virtual bool Stop(void) = 0;
39 };
40 
41 WX_DECLARE_LIST_2(wxGISNetServerConnection, wxGISNetServerConnectionList, wxGISNetServerConnectionNode, class WXDLLIMPEXP_GIS_NET);
42 
49 class WXDLLIMPEXP_GIS_NET wxGISNetworkService :
50  public wxEvtHandler,
51  public INetService
52 {
53  DECLARE_CLASS(wxGISNetworkService)
54 public:
56  virtual ~wxGISNetworkService(void);
58  //void OnSocketEvent(wxSocketEvent& pEvent);
59  //INetService
60  virtual bool Start(void);
61  virtual bool Stop(void);
62  virtual wxString GetServerName(void) const;
63  virtual bool CanConnect(const wxString &sName, const wxString &sPass);
64  virtual void AddConnection(wxGISNetServerConnection* pConn);
65  virtual bool DestroyConnection( wxGISNetServerConnection* pConn );
66  virtual void RemoveConnection( wxGISNetServerConnection* pConn );
67  //wxGISNetworkService
68  bool DestroyConnections();
69  void SendNetMessage(const wxNetMessage & msg, int nId = wxNOT_FOUND);
70  virtual void AddNetworkPlugin(const wxString &sClassName, const wxXmlNode *pConfigNode);
71 protected:
72  wxGISNetServerConnectionList& GetConnections() { return m_plNetworkConnections; }
73  //events
74  virtual void OnGISNetEvent(wxGISNetEvent& event);
75 protected:
76  short m_nMaxConnectoinCount;
77  int m_nConnectionCounter;
78  wxVector<INetPlugin*> m_paNetworkPlugins;
79  wxString m_sServerName;
80 
81  wxGISNetServerConnectionList m_plNetworkConnections;
82  int m_nConnectionIdCounter;
83  INetEventProcessor* m_pNetEvtProc;
84 private:
85  DECLARE_EVENT_TABLE()
86 };
87 
95 WXDLLIMPEXP_GIS_NET wxGISNetworkService* const GetNetworkService(void);
96 
102 WXDLLIMPEXP_GIS_NET void SetNetworkService(wxGISNetworkService* pService);
103 
104 
Definition: netevent.h:66
Definition: servernet.h:32
The network server connection interface class.
Definition: netconn.h:33
A Server side Network Service.
Definition: servernet.h:49
Definition: message.h:42
The network service base interface class.
Definition: netconn.h:70
Definition: netevent.h:34