libH/SocketClient.hpp

Go to the documentation of this file.
00001 
00012 /*
00013   
00014   Copyright (c) 2007, Tim Burrell
00015   Licensed under the Apache License, Version 2.0 (the "License");
00016   you may not use this file except in compliance with the License.
00017   You may obtain a copy of the License at 
00018 
00019         http://www.apache.org/licenses/LICENSE-2.0
00020 
00021   Unless required by applicable law or agreed to in writing, software
00022   distributed under the License is distributed on an "AS IS" BASIS,
00023   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00024   See the License for the specific language governing permissions and 
00025   limitations under the License. 
00026   
00027 */
00028 
00029 #ifndef __SocketClient_h
00030 #define __SocketClient_h
00031 
00032 #if HAVE_CONFIG_H
00033 #include "config.h"
00034 #endif
00035 
00036 #include "Socket.hpp"
00037 #include "SocketEventWatcher.hpp"
00038 #include <cstdlib>
00039 
00041 // Namespace
00043 
00044 namespace H {
00045 
00047 // Typedef's / Defines
00049                 
00051 // Class Definition
00053 
00060 class SocketClient : public Socket, private SocketEventWatcher {
00061 public:
00062         // Public Member Functions
00063         void                            connectToServer(std::string Host, int Port); 
00064         bool                            isClientConnected();            
00065         virtual void                    onSocketClientConnect(Socket const & socket); 
00066         virtual void                    onSocketClientDisconnect(Socket const & socket); 
00067         virtual void                    onSocketClientMessage(Socket const & socket, std::string const & Message); 
00068         virtual void                    onSocketClientRead(Socket const & socket, DynamicBuffer<char> & ReadBuffer); 
00069         void                            sendToServer(std::string const & Message); 
00070         
00071         // Construction / Deconstruction
00072         SocketClient();                                                 
00073         virtual ~SocketClient();                                        
00074 
00075 private:
00076         // Private Member Functions
00077         void                            onSocketConnect(SocketInterface const & iSocket); 
00078         void                            onSocketDisconnect(SocketInterface const & iSocket); 
00079         void                            onSocketMessage(SocketInterface const & iSocket, std::string const & Message); 
00080         void                            onSocketRead(SocketInterface const & iSocket, DynamicBuffer<char> & ReadBuffer); 
00081 
00082         // Private Member Variables
00083         bool                            mConnected;
00084 };
00085 
00087 
00088 } // H namespace
00089 
00090 #endif // __SocketClient_h

Generated on Wed Nov 7 10:04:16 2007 for gizmod by  doxygen 1.5.3