From 915005e218b5d00939b548de65ce6354f7acb487 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 28 Jul 2023 21:18:56 -0700 Subject: Completely redesigned Server and Client. Like, seriously, they're almost completely different. --- src/stable/client.h | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) (limited to 'src/stable/client.h') diff --git a/src/stable/client.h b/src/stable/client.h index abde682..4cd8e3f 100644 --- a/src/stable/client.h +++ b/src/stable/client.h @@ -12,7 +12,7 @@ #include "bu/config.h" #include "bu/string.h" -#include "bu/queuebuf.h" +#include "bu/clientbuf.h" #include "bu/mutex.h" #include "bu/readwritemutex.h" @@ -28,7 +28,6 @@ namespace Bu { class Protocol; class Stream; - class TcpSocket; class ClientLinkFactory; /** @@ -36,15 +35,13 @@ namespace Bu */ class Client : public Bu::Stream { + friend class Server; public: - Client( Bu::TcpSocket *pSocket, Bu::ClientLinkFactory *pfLink); + Client( Bu::ClientLinkFactory *pfLink ); virtual ~Client(); void processInput(); - void processOutput(); - //Bu::String &getInput(); - //Bu::String &getOutput(); Bu::size write( const Bu::String &sData ); Bu::size write( const void *pData, Bu::size nBytes ); Bu::size write( int8_t nData ); @@ -57,7 +54,7 @@ namespace Bu Bu::size write( uint64_t nData ); Bu::size read( void *pData, Bu::size nBytes ); Bu::size peek( void *pData, int nBytes, int nOffset=0 ); -// void seek( int nBytes ); + void seek( int nBytes ); Bu::size getInputSize(); Bu::size getOutputSize(); @@ -69,8 +66,6 @@ namespace Bu void close(); void tick(); - const Bu::TcpSocket *getSocket() const; - void disconnect(); bool wantsDisconnect(); @@ -78,31 +73,22 @@ namespace Bu void onMessage( const Bu::String &sMsg ); - bool hasOutput() { return qbWrite.getSize() > 0; } - bool hasInput() { return qbRead.getSize() > 0; } + bool hasOutput() { return cbBuffer.server().getSize() > 0; } + bool hasInput() { return cbBuffer.client().getSize() > 0; } template void pushFilter() { - filter *pFlt = new filter( *pTopStream ); - pTopStream = pFlt; - lFilts.prepend( pFlt ); } template void pushFilter( p1t p1 ) { - filter *pFlt = new filter( *pTopStream, p1 ); - pTopStream = pFlt; - lFilts.prepend( pFlt ); } template void pushFilter( p1t p1, p2t p2 ) { - filter *pFlt = new filter( *pTopStream, p1, p2 ); - pTopStream = pFlt; - lFilts.prepend( pFlt ); } /* @@ -128,18 +114,12 @@ namespace Bu virtual Bu::String getLocation() const; private: - typedef Bu::List FilterList; - FilterList lFilts; - Bu::Stream *pTopStream; - Bu::TcpSocket *pSocket; Bu::Protocol *pProto; - Bu::QueueBuf qbRead; - Bu::QueueBuf qbWrite; + Bu::ClientBuf cbBuffer; bool bWantsDisconnect; class Bu::ClientLinkFactory *pfLink; - Bu::Mutex mRead; - Bu::Mutex mWrite; - mutable Bu::ReadWriteMutex mGlobal; + mutable Bu::Mutex mProto; + mutable Bu::Mutex mDisconnect; }; } -- cgit v1.2.3