Fixed a typo and minor speedup in dtsc lib, fixed a bug when sending or receiving empty strings in socket lib.
This commit is contained in:
parent
2ad970f5df
commit
3ae5ac5be9
2 changed files with 4 additions and 4 deletions
|
@ -145,7 +145,7 @@ std::string & DTSC::Stream::lastData(){
|
||||||
return *datapointer;
|
return *datapointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the packed in this buffer number.
|
/// Returns the packet in this buffer number.
|
||||||
/// \arg num Buffer number.
|
/// \arg num Buffer number.
|
||||||
JSON::Value & DTSC::Stream::getPacket(unsigned int num){
|
JSON::Value & DTSC::Stream::getPacket(unsigned int num){
|
||||||
return buffers[num];
|
return buffers[num];
|
||||||
|
@ -169,7 +169,7 @@ bool DTSC::Stream::hasAudio(){
|
||||||
/// Returns a packed DTSC packet, ready to sent over the network.
|
/// Returns a packed DTSC packet, ready to sent over the network.
|
||||||
std::string & DTSC::Stream::outPacket(unsigned int num){
|
std::string & DTSC::Stream::outPacket(unsigned int num){
|
||||||
static std::string emptystring;
|
static std::string emptystring;
|
||||||
if (num >= buffers.size()) return emptystring;
|
if (num >= buffers.size() || !buffers[num].isObject()) return emptystring;
|
||||||
return buffers[num].toNetPacked();
|
return buffers[num].toNetPacked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -442,7 +442,7 @@ void Socket::Connection::Send(std::string & data){
|
||||||
/// \param len Amount of bytes to write.
|
/// \param len Amount of bytes to write.
|
||||||
/// \returns The amount of bytes actually written.
|
/// \returns The amount of bytes actually written.
|
||||||
int Socket::Connection::iwrite(const void * buffer, int len){
|
int Socket::Connection::iwrite(const void * buffer, int len){
|
||||||
if (!connected()){return 0;}
|
if (!connected() || len < 1){return 0;}
|
||||||
int r;
|
int r;
|
||||||
if (sock >= 0){
|
if (sock >= 0){
|
||||||
r = send(sock, buffer, len, 0);
|
r = send(sock, buffer, len, 0);
|
||||||
|
@ -479,7 +479,7 @@ int Socket::Connection::iwrite(const void * buffer, int len){
|
||||||
/// \param len Amount of bytes to read.
|
/// \param len Amount of bytes to read.
|
||||||
/// \returns The amount of bytes actually read.
|
/// \returns The amount of bytes actually read.
|
||||||
int Socket::Connection::iread(void * buffer, int len){
|
int Socket::Connection::iread(void * buffer, int len){
|
||||||
if (!connected()){return 0;}
|
if (!connected() || len < 1){return 0;}
|
||||||
int r;
|
int r;
|
||||||
if (sock >= 0){
|
if (sock >= 0){
|
||||||
r = recv(sock, buffer, len, 0);
|
r = recv(sock, buffer, len, 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue