Version: 0.6.0
netconn.h
1 /******************************************************************************
2  * Project: wxGIS
3  * Purpose: network conection classes.
4  * Author: Dmitry Baryshnikov (aka Bishop), polimax@mail.ru
5  ******************************************************************************
6 * Copyright (C) 2012-2013 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/network.h"
24 
25 #include "wx/socket.h"
26 #include "wx/xml/xml.h"
27 
28 class INetService;
29 
33 class WXDLLIMPEXP_GIS_NET wxGISNetServerConnection : public INetConnection
34 {
35  DECLARE_CLASS(wxGISNetServerConnection)
36  enum{
37  // id for sockets
38  SOCKET_ID = 103,
39  // id for auth timer
40  TIMER_ID = 1014
41  };
42 public:
44  //wxGISNetServerConnection(wxSocketBase* sock);
45  virtual ~wxGISNetServerConnection(void);
46  virtual void SetNetworkService(INetService* pNetService);
47  virtual void SetSocket(wxSocketBase* sock);
48  virtual bool Destroy(void);
49 // virtual void SetAuth(AUTHRESPOND sUserInfo) = 0;//set user authenticated state true
50  //virtual AUTHRESPOND GetAuth(void) = 0; // get if user has been authenticated
51  //virtual void SetAlive(wxDateTime dtm) = 0;
52  //virtual wxDateTime GetAlive(void) = 0;
53 protected:
54  //events
55  virtual void OnSocketEvent(wxSocketEvent& event);
56  virtual void OnTimer( wxTimerEvent & event);
57 protected:
58  virtual bool ProcessInputNetMessage(void);
59 protected:
60  INetService* m_pNetService;
61  wxTimer m_timer;
62 private:
63  DECLARE_EVENT_TABLE()
64 };
65 
66 
71 {
72 public:
73  virtual ~INetService(void){};
74  virtual bool Start(void) = 0;
75  virtual bool Stop(void) = 0;
76  virtual wxString GetServerName(void) const = 0;
77  virtual bool CanConnect(const wxString &sName, const wxString &sPass) = 0;
78  virtual void AddConnection(wxGISNetServerConnection* pConn) = 0;
79  virtual bool DestroyConnection( wxGISNetServerConnection* pConn ) = 0;
80  virtual void RemoveConnection( wxGISNetServerConnection* pConn ) = 0;
81 };
82 
88 class WXDLLIMPEXP_GIS_NET wxGISNetClientConnection : public INetConnection
89 {
90  DECLARE_ABSTRACT_CLASS(wxGISNetClientConnection)
91 public:
93  virtual ~wxGISNetClientConnection(void);
94  virtual bool HasAttributes(void) const;
95  //pure virtual
102  virtual wxJSONValue GetAttributes(void) const = 0;
109  virtual bool SetAttributes(const wxJSONValue& oProperties) = 0;
110 
111  virtual wxString GetName(void) const;
112  virtual wxString GetLastError(void) const;
113  };
114 
The JSON value class implementation.
Definition: jsonval.h:91
The network connection interface class.
Definition: netconn.h:88
The network server connection interface class.
Definition: netconn.h:33
Definition: network.h:74
The network service base interface class.
Definition: netconn.h:70