/home/tetron/hack/vos/libs/vos/vos/remotesocketsite.hh
Go to the documentation of this file.00001 #ifndef _REMOTESOCKETSITE_HH_
00002 #define _REMOTESOCKETSITE_HH_
00003
00004 #include <stdexcept>
00005
00006 #include <vos/vos/siteextension.hh>
00007 #include <vos/vos/message.hh>
00008 #include <vos/vos/messageblock.hh>
00009 #include <vos/vos/remotesite.hh>
00010
00011 namespace VOS {
00012
00013
00014
00015
00016
00017 class VOS_API RemoteSocketSiteExtension : public RemoteSiteExtension
00018 {
00019 private:
00020 int socketFD;
00021 VUtil::vRef<MessageBlock> partialMessage;
00022 unsigned int sockSendBufSz;
00023 boost::mutex outputBuffer_mutex;
00024 std::string outputBuffer;
00025 Site* remotesite;
00026 std::string hostname;
00027 std::string remoteport;
00028
00029 public:
00030
00031
00032
00033
00034 RemoteSocketSiteExtension(int socket, sockaddr_in* peername);
00035
00036
00037
00038
00039
00040 RemoteSocketSiteExtension(const std::string& hostname, unsigned short int port);
00041
00042
00043 virtual ~RemoteSocketSiteExtension();
00044
00045
00046 virtual void siteExtensionAttachedTo(Site* st);
00047
00048
00049 VUtil::vRef<Site> getRemoteSite() { return VUtil::vRef<Site>(remotesite, true); }
00050
00051
00052 int getSocket() { return socketFD; }
00053
00054
00055 bool needWriteFlush() { return (outputBuffer.size() > 0); }
00056
00057
00058
00059
00060
00061 int readStream(char* data, unsigned int datasize);
00062
00063
00064
00065
00066
00067 int writeStream(const char* data, unsigned int datasize);
00068
00069
00070 void handleDisconnection();
00071
00072
00073
00074
00075 virtual std::list< VUtil::vRef<MessageBlock> > readQueuedMessages(bool block);
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 void pushOutgoingBuffer(const char* newdata = 0, unsigned int newsize = 0);
00086
00087
00088
00089
00090
00091 virtual void doSendMessage(VobjectState& state, Message* m);
00092
00093
00094
00095
00096
00097
00098 virtual void doSendMessage(VobjectState& state, MessageBlock* m);
00099
00100 virtual bool isConnected();
00101 };
00102 };
00103
00104 #ifndef VOS_EXPORTS
00105 IMPORT_METAOBJECT_FACTORIES(SocketProtocolHandler)
00106 #endif
00107
00108 #endif