libs.net: complete network functionality
[WeStealzYourDataz.git] / src / uk / ac / ntu / n0521366 / wsyd / libs / net / NetworkMessage.java
index a3e9dd3..a513e72 100644 (file)
@@ -58,6 +58,11 @@ public class NetworkMessage implements Serializable, Cloneable {
      * Filled in by the message originator with the title of the destination service
      */
     String _serviceTarget;
+    
+    /**
+     * Optional user key of a NetworkStream to enable TCP to send userID on connection
+     */
+    long _key;
 
     Class<?> _class;
     MessageAbstract _message;
@@ -83,7 +88,7 @@ public class NetworkMessage implements Serializable, Cloneable {
      * contain native types that are serializable
      * @throws IllegalArgumentException 
      */
-    NetworkMessage(String intent, String target, MessageAbstract message) throws IllegalArgumentException {
+    public NetworkMessage(String intent, String target, MessageAbstract message) throws IllegalArgumentException {
         _serializeLength = -1;
         if ( !(intent != null && intent.length() > 0) ) 
             throw(new IllegalArgumentException("intent cannot be null or empty"));
@@ -166,6 +171,24 @@ public class NetworkMessage implements Serializable, Cloneable {
         return _serializeLength;
     }
     
+    /**
+     * Set the key of the TCP stream in the messsage.
+     * 
+     * @param key 
+     */
+    public void setKey(long key) {
+        _key = key;
+    }
+    
+    /**
+     * Get the key set by the ServerTCP.
+     * 
+     * @return the key of the stream associated
+     */
+    public long getKey() {
+        return _key;
+    }
+    
     /**
      * Create a message for passing over the network.
      *