src/proto2/NetworkTCP.hh
branchno-netsession
changeset 32 2ff929186c90
parent 31 d0d7489d4e8b
child 33 e53f09b378f4
--- a/src/proto2/NetworkTCP.hh	Mon Nov 10 16:49:09 2008 +0000
+++ b/src/proto2/NetworkTCP.hh	Mon Nov 10 18:21:23 2008 +0000
@@ -18,20 +18,27 @@
         size_t size, off;
 
         NetworkSocket &socket;
-
+    
     public:
         NetworkBuffer (NetworkSocket &socket, size_t size_hint);
-    
+ 
     private:
-        void resize (size_t new_size);
+        NetworkBuffer (const NetworkBuffer &copy) { };
+        ~NetworkBuffer (void);
+        NetworkBuffer& operator= (const NetworkBuffer &copy) { };
+
+        void resize (size_t suffix_size);
+        void trim (size_t prefix_size);
 
     public:    
-        void write (const char *buf, size_t size);
-        void read (char *buf, size_t size);
-
+        void push_write (char *buf_ptr, size_t buf_size);
         void flush_write (void);
-
-        template <typename T> bool read_prefix (T &val_ref);
+        template <typename PrefixType> void write_prefix (char *buf, PrefixType prefix);
+        
+        void try_read (size_t item_size);
+        bool peek_prefix (uint16_t &ref);
+        bool peek_prefix (uint32_t &ref);
+        template <typename PrefixType> PrefixType read_prefix (char *buf_ptr, size_t buf_max);
 };
 
 class NetworkTCPTransport {
@@ -51,11 +58,11 @@
         void on_write (void);
         void on_disconnected (void);
 
-    protected:
+    public:
         void write_packet (const NetworkPacket &packet);
         
-        virtual void handle_packet (const NetworkPacket &packet) = 0;
-        virtual void handle_disconnect (void) = 0;
+        CL_Signal_v1<const NetworkPacket&> sig_packet;
+        CL_Signal_v0 sig_disconnect;
 };
 
 class NetworkTCPServer {
@@ -68,8 +75,8 @@
     private:
         void on_accept (void);
 
-    protected:
-        virtual void handle_client (NetworkTCPTransport *client) = 0;
+    public:
+        CL_Signal_v1<NetworkTCPTransport *> sig_client;
 };
 
 class NetworkTCPClient : public NetworkTCPTransport {