00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef EchoServer_h_DEFINED
00013 #define EchoServer_h_DEFINED
00014
00015 #include <OPENR/OObject.h>
00016 #include <OPENR/OSubject.h>
00017 #include <OPENR/OObserver.h>
00018 #include "TCPConnection.h"
00019 #include "EchoServerConfig.h"
00020 #include "def.h"
00021
00022 class EchoServer : public OObject {
00023 public:
00024 EchoServer();
00025 virtual ~EchoServer() {}
00026
00027 OSubject* subject[numOfSubject];
00028 OObserver* observer[numOfObserver];
00029
00030 virtual OStatus DoInit (const OSystemEvent& event);
00031 virtual OStatus DoStart (const OSystemEvent& event);
00032 virtual OStatus DoStop (const OSystemEvent& event);
00033 virtual OStatus DoDestroy(const OSystemEvent& event);
00034
00035 void ListenCont (ANTENVMSG msg);
00036 void SendCont (ANTENVMSG msg);
00037 void ReceiveCont(ANTENVMSG msg);
00038 void CloseCont (ANTENVMSG msg);
00039
00040 private:
00041 OStatus Listen (int index);
00042 OStatus Send (int index);
00043 OStatus Receive(int index);
00044 OStatus Close (int index);
00045 OStatus InitTCPConnection(int index);
00046
00047 void SetSendData(int index);
00048 void SetReceiveData(int index);
00049
00050 antStackRef ipstackRef;
00051 TCPConnection connection[ECHOSERVER_CONNECTION_MAX];
00052 };
00053
00054 #endif // EchoServer_h_DEFINED