00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #pragma once
00011 #include "ippdme/Server/ippEngine.h"
00012 #include "ippdme/Socket/ippSocket.h"
00013 #include "ippdme/Command/ippCommand.h"
00014 #include "ippdme/Response/ippResponse.h"
00015
00016 class ippCommand;
00017
00018 class IPPDME_EXT_CLASS ippSimpleClient : public ippEngine
00019 {
00020 public:
00021 enum STATE{
00022 disconnected,
00023 trying_to_connect,
00024 connected,
00025 };
00026
00027 ippSimpleClient();
00028
00029
00030
00032 void Connect(const char* hostname,int port = 1294);
00033
00035 STATE GetState() const;
00036
00038 void Disconnect();
00039
00041 virtual void HeartBeat();
00042
00043
00046 bool ReadyToSend() const;
00047
00050 bool NeedToSendClearAllErrors() const;
00051
00052
00053
00054
00055
00057 virtual void OnConnectionLost();
00059 virtual void OnResponse(ippResponsePtr response);
00060 virtual void OnDaemonResponse(ippResponsePtr response);
00061 virtual void OnErrorResponse(ippResponsePtr response);
00063 virtual void OnUnsollicitedEvent(ippResponsePtr response);
00065 virtual void OnComnmandCompleted(int tagNumber);
00066
00067
00068
00070 void ClearAllErrors();
00071
00075 bool InErrorState() const { return _in_error_state; }
00076
00077
00079 bool SendCommand(ippCommandConstPtr command);
00080
00082
00083
00084 void SendCommand(const char* command_string);
00085
00087 int NumberOfUncompletedCommandsInQueue();
00088
00089
00090 protected:
00091 friend class ippSimpleServerTestCase;
00092
00093
00094
00095 protected:
00096 void PerformWrite();
00097
00098
00099 virtual void ProcessLine(const char* inputline);
00100 virtual void ProcessMisformedLine(const char* inputline);
00101
00102 private:
00103 STATE _state;
00104
00105 bool _ready_to_send;
00106 int _pending_tag;
00107 std::queue<int> _pending_commands;
00108 int _next_tag;
00109 bool _in_error_state;
00110
00111 };