aboutsummaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 2f293b7..8077b3d 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -99,9 +99,9 @@ bool Bu::Client::isOpen()
99 return pSocket->isOpen(); 99 return pSocket->isOpen();
100} 100}
101 101
102void Bu::Client::write( const char *pData, int nBytes ) 102void Bu::Client::write( const void *pData, int nBytes )
103{ 103{
104 sWriteBuf.append( pData, nBytes ); 104 sWriteBuf.append( (const char *)pData, nBytes );
105} 105}
106 106
107void Bu::Client::write( int8_t nData ) 107void Bu::Client::write( int8_t nData )
@@ -144,7 +144,7 @@ void Bu::Client::write( uint64_t nData )
144 sWriteBuf.append( (const char *)&nData, sizeof(nData) ); 144 sWriteBuf.append( (const char *)&nData, sizeof(nData) );
145} 145}
146 146
147void Bu::Client::read( char *pData, int nBytes ) 147void Bu::Client::read( void *pData, int nBytes )
148{ 148{
149 memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes ); 149 memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes );
150 nRBOffset += nBytes; 150 nRBOffset += nBytes;
@@ -165,6 +165,31 @@ void Bu::Client::read( char *pData, int nBytes )
165 } 165 }
166} 166}
167 167
168void Bu::Client::peek( void *pData, int nBytes )
169{
170 memcpy( pData, sReadBuf.getStr()+nRBOffset, nBytes );
171}
172
173void Bu::Client::seek( int nBytes )
174{
175 nRBOffset += nBytes;
176 if( sReadBuf.getSize()-nRBOffset == 0 )
177 {
178 sReadBuf.clear();
179 nRBOffset = 0;
180 }
181 // This is an experimental threshold, maybe I'll make this configurable
182 // later on.
183 else if(
184 (sReadBuf.getSize() >= 1024 && nRBOffset >= sReadBuf.getSize()/2) ||
185 (nRBOffset >= sReadBuf.getSize()/4)
186 )
187 {
188 sReadBuf.trimFront( nRBOffset );
189 nRBOffset = 0;
190 }
191}
192
168long Bu::Client::getInputSize() 193long Bu::Client::getInputSize()
169{ 194{
170 return sReadBuf.getSize()-nRBOffset; 195 return sReadBuf.getSize()-nRBOffset;
@@ -175,3 +200,7 @@ const Bu::Socket *Bu::Client::getSocket() const
175 return pSocket; 200 return pSocket;
176} 201}
177 202
203void Bu::Client::disconnect()
204{
205}
206