Version: 0.6.0
tcpnetworkplugin.h
1 /******************************************************************************
2  * Project: wxGIS (GIS Server)
3  * Purpose: TCP network server plugin class.
4  * Author: Bishop (aka Barishnikov Dmitriy), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2010 Bishop
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 "wxgissrv/srv_framework/framework.h"
24 #include "wxgissrv/srv_framework/network.h"
25 
29 class WXDLLIMPEXP_GIS_NET wxServerTCPNetworkPlugin : public INetworkPlugin
30 {
31  DECLARE_DYNAMIC_CLASS(wxServerTCPNetworkPlugin)
32 
33  enum{
34  // id for sockets
35  UDP_SERVER_ID = 100,
36  TCP_SERVER_ID
37  };
38 public:
40  virtual ~wxServerTCPNetworkPlugin(void);
41  bool CreateUDPNotifier(void);
42  bool CreateListenSocket(void);
43  //INetworkPlugin
44  virtual bool Start(INetworkService* pNetService, wxXmlNode* pConfig);
45  virtual bool Stop(void);
46  //events
47  virtual void OnUDPServerEvent(wxSocketEvent& event);
48  virtual void OnTCPServerEvent(wxSocketEvent& event);
49 protected:
50  int m_nPort, m_nAdvPort;
51  wxString m_sAddr;
52  INetworkService* m_pNetService;
53  wxDatagramSocket *m_udp_socket;
54  wxSocketServer* m_listeningSocket;
55 
56  DECLARE_EVENT_TABLE()
57 };
58 
59 /*
60 #include "wxgissrv/srv_networking/networking.h"
61 
62 #include "wxgis/networking/tcpnetwork.h"
63 /*
67 class wxServerUDPNotifier : public wxThread
68 {
69 public:
70  wxServerUDPNotifier(wxString sServName, wxString sAddr = wxEmptyString, int nPort = 1976, int nAdvPort = 1977);
71  virtual void *Entry();
72  virtual void OnExit();
73 private:
74  wxDatagramSocket *m_socket;
75  wxString m_sServName;
76  wxString m_sAddr;
77  int m_nPort, m_nAdvPort;
78 };
79 /*
83 class WXDLLIMPEXP_GIS_NET wxServerTCPWaitAccept : public wxThread
84 {
85 public:
86  wxServerTCPWaitAccept(wxString sListenAddr, int nListenPort, wxGISNetworkService* pGISNetworkService);
87  virtual void *Entry();
88  virtual void OnExit();
89 protected:
90  wxSocketServer* m_pSock;
91  wxGISNetworkService* m_pGISNetworkService;
92 };
93 
94 class WXDLLIMPEXP_GIS_NET wxServerTCPNetConnection;/*
98 class WXDLLIMPEXP_GIS_NET wxServerTCPWaitLost : public wxThread
99 {
100 public:
101  wxServerTCPWaitLost(wxServerTCPNetConnection* pConnection, wxSocketBase* pSock);
102  virtual void *Entry();
103  virtual void OnExit();
104 protected:
105  wxServerTCPNetConnection* m_pConnection;
106  wxSocketBase* m_pSock;
107 };
108 /*
112 class WXDLLIMPEXP_GIS_NET wxServerTCPNetConnection :
113  public wxObject,
114  public INetServerConnection
115 {
116 public:
117  wxServerTCPNetConnection(wxSocketBase* pSocket, wxGISNetworkService* pGISNetworkService);
118  ~wxServerTCPNetConnection(void);
119  //INetConnection
120  virtual bool Connect(void);
121  virtual bool Disconnect(void);
122  virtual void PutInMessage(WXGISMSG msg);
123  //INetServerConnection
124  virtual void SetAuth(AUTHRESPOND stUserInfo){m_stUserInfo = stUserInfo;};
125  virtual AUTHRESPOND GetAuth(void){return m_stUserInfo;};
126  virtual void SetAlive(wxDateTime dtm){m_LastAlive = dtm;};
127  virtual wxDateTime GetAlive(void){return m_LastAlive;};
128 protected:
129  wxSocketBase* m_pSock;
130  wxGISNetworkService* m_pGISNetworkService;
131  wxNetTCPReader* m_pServerTCPReader;
132  wxNetTCPWriter* m_pServerTCPWriter;
133 // wxNetTCPWaitlost* m_pServerTCPWaitlost;
134  wxServerTCPWaitLost* m_pServerTCPWaitlost;
135  AUTHRESPOND m_stUserInfo;
136  wxDateTime m_LastAlive;
137 };
138 
139 /*
143 class WXDLLIMPEXP_GIS_NET wxServerTCPNetworkPlugin :
144  public wxObject,
145  public INetworkPlugin
146 {
147  DECLARE_DYNAMIC_CLASS(wxServerTCPNetworkPlugin)
148 public:
149  wxServerTCPNetworkPlugin(void);
150  virtual ~wxServerTCPNetworkPlugin(void);
151  virtual bool Start(wxGISNetworkService* pNetService, wxXmlNode* pConfig);
152  virtual bool Stop(void);
153  //virtual int GetPort(void){return m_nPort;};
154  //virtual wxString GetAddress(void){return m_sAddr;};
155  //virtual wxString GetServerName(void){return m_pApp->GetServerName();};
156  //virtual bool CanAcceptConnection(void){return m_pApp->CanAcceptConnection();};
157  //virtual bool AddConnection();
158  //virtual void RemoveConnection(long nID);
159 protected:
160  int m_nPort, m_nAdvPort;
161  wxString m_sAddr;
162  //wxXmlNode* m_pConfig;
163  wxGISNetworkService* m_pNetService;
164  wxServerTCPWaitAccept* m_pWaitThread;
165  wxServerUDPNotifier* m_pServerUDPNotifier;
166 };
167 */
The network service base interface class.
Definition: netconn.h:68
A Server side INetworkPlugin interface.
Definition: networkplugin.h:30
A Server side TCPNetworkPlugin.
Definition: tcp.h:32