Add a main for FileSender. It now works we can use this little class for more
authorDa Risk <darisk972@gmail.com>
Thu, 12 Mar 2009 23:26:27 +0100
changeset 10 d26672ed3763
parent 9 31fdf68dc4df
child 11 20a2c2b04060
Add a main for FileSender. It now works we can use this little class for more test.
src/com/beem/project/beem/jingle/FileSender.java
--- a/src/com/beem/project/beem/jingle/FileSender.java	Thu Mar 12 22:27:36 2009 +0100
+++ b/src/com/beem/project/beem/jingle/FileSender.java	Thu Mar 12 23:26:27 2009 +0100
@@ -28,12 +28,15 @@
 	    OutputStream out = new BufferedOutputStream(sock.getOutputStream());
 
 	    try {
+		// peut etre se debarasser de started
 		started = true;
 		byte buf[] = new byte[1024];
 		int nbbytes = 1;
-		while (started && nbbytes != -1){
+		while (started){
 		    nbbytes = in.read(buf, 0, 1024);
-		    out.write(buf, 0, 1024);
+		    if (nbbytes == -1)
+			break;
+		    out.write(buf, 0, nbbytes);
 		}
 		started = false;
 	    } finally {
@@ -55,5 +58,10 @@
 	started = false;
     }
 
+    public static void main(String args[]) throws InterruptedException {
+	FileSender fs = new FileSender("localhost", 4242, "/tmp/img.jpeg");
+	fs.start();
+	fs.join();
+    }
 
 }