Easy Simple Network Library  0.3.7
All Classes Functions Modules
Client.h
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of "esnetwork" library.
4 It is licensed under the terms of the BSD license.
5 For the latest info, see http://esnetwork.sourceforge.net
6 
7 Copyright (c) 2012-2013 Lin Jia Jun (Joe Lam)
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 
13 1. Redistributions of source code must retain the above copyright notice, this
14  list of conditions and the following disclaimer.
15 2. Redistributions in binary form must reproduce the above copyright notice,
16  this list of conditions and the following disclaimer in the documentation
17  and/or other materials provided with the distribution.
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 -----------------------------------------------------------------------------
30 */
31 
32 #ifndef _ESN_CLIENT_H_
33 #define _ESN_CLIENT_H_
34 
35 #include "IoFilter.h"
36 #include "IoHandler.h"
37 #include "IoBufferManager.h"
38 #include "IoServiceManager.h"
39 
40 namespace esnlib
41 {
42 
44 class Client
45 {
46 public:
47  Client();
48  virtual ~Client();
49 
55  virtual bool Connect(const std::string& svraddr, int svrport) = 0;
56 
58  virtual void Disconnect() = 0;
59 
63  virtual bool Connected() = 0;
64 
68  virtual bool IsConnecting() = 0;
69 
73  virtual void Write(IoBufferPtr data) = 0;
74 
78  virtual void Write(void* data) = 0;
79 
83  virtual void SetConnectTimeOut(int seconds) = 0;
84 
89  virtual void SetIdleTime(int idletype, int idletime) = 0;
90 
94  virtual void SetIoHandler(IoHandlerPtr handler) = 0;
95 
99  virtual void SetIoFilter(IoFilterPtr filter) = 0;
100 
104  virtual void SetIoBufferManager(IoBufferManagerPtr manager) = 0;
105 
109  virtual void SetIoServiceManager(IoServiceManagerPtr manager) = 0;
110 
115  virtual IoBufferPtr GetFreeBuffer(int bufsize) = 0;
116 
120  virtual std::string GetDefaultLocalIp() = 0;
121 
125  virtual std::string GetLocalIp() = 0;
126 
130  virtual int GetLocalPort() = 0;
131 
135  virtual std::string GetRemoteIp() = 0;
136 
140  virtual int GetRemotePort() = 0;
141 
145  virtual SessionPtr GetCurrentSession() = 0;
146 
150  virtual int GetId() = 0;
151 
155  virtual void SetId(int id) = 0;
156 
160  virtual bool HasGlobalData() = 0;
161 
165  virtual CommonDataPtr GetGlobalData() = 0;
166 
174  virtual bool EnableSsl(bool needverify = true, const std::string& verifyfile = std::string(),
175  const std::string& certfile = std::string(), const std::string& keyfile = std::string()) = 0;
176 
180  virtual bool HasSsl() = 0;
181 
182 
183 protected:
184 private:
185 };
186 
187 typedef boost::shared_ptr<Client> ClientPtr;
188 
193 ClientPtr CreateClient(int readBufferSize = 8192, int writeBufferSize = 8192);
199 
202 }
203 
204 #endif // _ESN_CLIENT_H_
205 
virtual void SetIoBufferManager(IoBufferManagerPtr manager)=0
virtual SessionPtr GetCurrentSession()=0
virtual int GetRemotePort()=0
virtual bool IsConnecting()=0
virtual IoBufferPtr GetFreeBuffer(int bufsize)=0
virtual void Disconnect()=0
Disconnect the server.
virtual void SetIoHandler(IoHandlerPtr handler)=0
virtual bool HasGlobalData()=0
virtual std::string GetLocalIp()=0
virtual void SetConnectTimeOut(int seconds)=0
Client class (interface)
Definition: Client.h:44
ClientPtr CreateClient(int readBufferSize=8192, int writeBufferSize=8192)
virtual void SetIoFilter(IoFilterPtr filter)=0
virtual int GetId()=0
virtual void SetIoServiceManager(IoServiceManagerPtr manager)=0
virtual int GetLocalPort()=0
virtual std::string GetRemoteIp()=0
virtual bool Connected()=0
virtual bool HasSsl()=0
virtual void Write(IoBufferPtr data)=0
Definition: Buffer.h:37
virtual bool Connect(const std::string &svraddr, int svrport)=0
virtual bool EnableSsl(bool needverify=true, const std::string &verifyfile=std::string(), const std::string &certfile=std::string(), const std::string &keyfile=std::string())=0
virtual void SetId(int id)=0
virtual CommonDataPtr GetGlobalData()=0
virtual void SetIdleTime(int idletype, int idletime)=0
virtual std::string GetDefaultLocalIp()=0