Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

temporary fix (avoiding TalkySerialisable. check back to http://www.c…

  • Loading branch information...
commit f23800286389f76b8aef6581907069206dbcadf1 1 parent 41b28cb
Elliot Woods authored October 13, 2011
2  src/TalkyBase.h
@@ -8,7 +8,7 @@
8 8
 //
9 9
 
10 10
 
11  
-#define TALKY_SLEEP_TIME 10
  11
+#define TALKY_SLEEP_TIME_MILLIS 10
12 12
 #define TALKY_RECONNECT_TIME 200
13 13
 #define TALKY_DEFAULT_PORT 5001
14 14
 
14  src/TalkyBuffer.cpp
@@ -200,7 +200,8 @@ namespace Talky {
200 200
 		
201 201
 		//clear our local data and replace
202 202
 		//with section of other buffer's data
203  
-		setData(other.getData(), s);
  203
+		setData(other.getReadPointer(), s);
  204
+		other.advanceReadPointer(s);
204 205
 		
205 206
 		return true;
206 207
 	}
@@ -305,4 +306,15 @@ namespace Talky {
305 306
 			throw ("TalkyBuffer::advanceReadPointer : Buffer overrun error");
306 307
 	}
307 308
 	
  309
+	//------
  310
+	
  311
+	TalkyBuffer& operator<<(TalkyBuffer &b, TalkySerialisable const &o) {
  312
+		o.serialiseToBuffer(b);
  313
+		return b;
  314
+	}
  315
+	
  316
+	bool operator>>(TalkyBuffer &b, TalkySerialisable& o) {
  317
+		return o.deSerialiseFromBuffer(b);
  318
+	}	
  319
+	
308 320
 }
19  src/TalkyBuffer.h
@@ -33,7 +33,7 @@ namespace Talky {
33 33
 		virtual bool	deSerialiseFromBuffer(TalkyBuffer &b) = 0;
34 34
 	};
35 35
 	
36  
-	class TalkyBuffer : TalkySerialisable {
  36
+	class TalkyBuffer : public TalkySerialisable {
37 37
 	public:
38 38
 		TalkyBuffer();
39 39
 		TalkyBuffer(BufferOffset size);
@@ -59,7 +59,7 @@ namespace Talky {
59 59
 		bool		hasSpaceToRead(BufferOffset size) const;
60 60
 		BufferOffset	getRemainingWriteSpace() const;
61 61
 		BufferOffset	getRemainingReadSpace() const;
62  
-				
  62
+		
63 63
 		template<class T>
64 64
 		TalkyBuffer& operator<<(T const &object) {
65 65
 			if (!write(&object, sizeof(T)))
@@ -67,14 +67,6 @@ namespace Talky {
67 67
 			return *this;
68 68
 		}
69 69
 		
70  
-/*		template<class T>
71  
-		TalkyBuffer& operator<<(T const object) {
72  
-			if (!write(&object, sizeof(T)))
73  
-				throw("Buffer overrun - insufficient space to write");
74  
-			return *this
75  
-		}
76  
-*/		
77  
-		
78 70
 		template<class T>
79 71
 		bool operator>>(T& object) {
80 72
 			return read(&object, sizeof(T));
@@ -84,7 +76,6 @@ namespace Talky {
84 76
 		string toString(unsigned short maxLength=10) const;
85 77
 		
86 78
 		
87  
-		
88 79
 		/**
89 80
 		 Hard ass access. You sure you really want to do this??
90 81
 		 We need this in TalkyBase, consider moving to 'friend' class?
@@ -150,5 +141,9 @@ namespace Talky {
150 141
 		BufferOffset	writeOffset;
151 142
 		
152 143
 	};
153  
-
  144
+	
  145
+	///Overload template when serialising a TalkySerialisable object
  146
+	TalkyBuffer& operator<<(TalkyBuffer& b, TalkySerialisable const &o);
  147
+	///Overload template when deserialising to a TalkySerialisable object
  148
+	bool operator>>(TalkyBuffer& b, TalkySerialisable &o);
154 149
 }
4  src/TalkyMessage.cpp
@@ -120,7 +120,7 @@ namespace Talky {
120 120
 		
121 121
 		buf << TALKY_START_TOKEN;
122 122
 		buf << header;
123  
-		buf << payload;
  123
+		buf << (TalkySerialisable&) payload;
124 124
 		buf << TALKY_END_TOKEN;		
125 125
 		
126 126
 		return true;		
@@ -139,7 +139,7 @@ namespace Talky {
139 139
 			 throw("Message corrupt!");
140 140
 		
141 141
 		buf >> header;
142  
-		buf >> payload;
  142
+		buf >> (TalkySerialisable&) payload;
143 143
 		
144 144
 		buf >> token;
145 145
 		if (token != TALKY_END_TOKEN)
4  src/TalkyMessage.h
@@ -124,8 +124,8 @@ namespace Talky {
124 124
 	
125 125
 	//-----
126 126
 	
127  
-	///Used when putting a message onto main buffer
  127
+	///Used when putting a message onto main buffer (tx)
128 128
 	TalkyBuffer& operator<<(TalkyBuffer& b, TalkyMessage const &m);
129  
-	///Used when pulling a message off main buffer
  129
+	///Used when pulling a message off main buffer (rx)
130 130
 	bool operator>>(TalkyBuffer& b, TalkyMessage &m);
131 131
 }

0 notes on commit f238002

Please sign in to comment.
Something went wrong with that request. Please try again.