Permalink
Browse files

Merge commit '76f6a1986c638a89294e7d0541946f156b8d548f'

  • Loading branch information...
elliotwoods committed Dec 9, 2011
2 parents a04f3f8 + 76f6a19 commit 5fa91eb18770ecfbd3ad13d9bbb230bc91192062
Showing with 23 additions and 6 deletions.
  1. +10 −1 src/TalkyBase.cpp
  2. +6 −1 src/TalkyBase.h
  3. +5 −4 src/TalkyBuffer.cpp
  4. +2 −0 src/TalkyBuffer.h
View
@@ -154,7 +154,13 @@ namespace Talky {
void TalkyBase::clearMessages()
{
while (!lockThread())
+ {
+#ifdef _WIN32
+ Sleep(1);
+#else
sleep(10);
+#endif
+ }
receiveQueue.clear();
@@ -298,7 +304,10 @@ namespace Talky {
bool TalkyBase::rxServer(int iClient) {
const int nBytesReceived = rxServer(iClient, _bufferIn.getWritePointer(), _bufferIn.getRemainingWriteSpace());
- _bufferIn.advanceWritePointer(nBytesReceived);
+ try
+ {
+ _bufferIn.advanceWritePointer(nBytesReceived);
+ } catch
}
bool TalkyBase::rxClient() {
View
@@ -7,7 +7,6 @@
// Copyright 2011 Kimchi and Chips. All rights reserved.
//
-
#define TALKY_SLEEP_TIME_MILLIS 10
#define TALKY_RECONNECT_TIME 200
#define TALKY_DEFAULT_PORT 5001
@@ -16,11 +15,17 @@
#define TALKY_BUFFER_OUT_SIZE 100000
#include "TalkyMessage.h"
+#include "TalkyException.h"
#include <vector>
#include <ctime>
#include <iostream>
#include <sstream>
+#include <algorithm>
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
using namespace std;
View
@@ -41,9 +41,10 @@ namespace Talky {
readOffset = other.getReadOffset();
writeOffset = other.getWriteOffset();
-
_data = new char[allocatedSize];
memcpy(_data, other.getData(), allocatedSize);
+
+ return *this;
}
//------
@@ -187,7 +188,7 @@ namespace Talky {
other << s;
if (!other.write(getData(), s))
- throw("Buffer overrun - insufficient space to write");
+ throw(new TalkyException("Buffer overrun - insufficient space to write"));
}
bool TalkyBuffer::deSerialiseFromBuffer(TalkyBuffer &other) {
@@ -292,7 +293,7 @@ namespace Talky {
writtenSize = writeOffset;
if (s > allocatedSize)
- throw ("TalkyBuffer::advanceWritePointer : Buffer overrun error");
+ throw (new TalkyException("TalkyBuffer::advanceWritePointer : Buffer overrun error"));
}
char* TalkyBuffer::getReadPointer() {
@@ -303,7 +304,7 @@ namespace Talky {
readOffset += s;
if (s > allocatedSize)
- throw ("TalkyBuffer::advanceReadPointer : Buffer overrun error");
+ throw (new TalkyException("TalkyBuffer::advanceReadPointer : Buffer overrun error"));
}
//------
View
@@ -12,6 +12,8 @@
#include <iostream>
#include <fstream>
+#include "TalkyException.h"
+
using namespace std;
namespace Talky {

0 comments on commit 5fa91eb

Please sign in to comment.