[Red5commits] [1728] --

lhubbard luke at codegent.com
Mon Feb 12 13:50:10 EST 2007


--


Timestamp: 02/12/07 13:44:45 EST (less than one hour ago) 
Change: 1728 
Author: lhubbard

Files (see diff or trac for details): 
java/server/trunk/src/org/red5/server/net/udp/BasicHandler.java


Trac: http://mirror1.cvsdude.com/trac/osflash/red5/changeset/1728

Index: /java/server/trunk/src/org/red5/server/net/udp/BasicHandler.java
===================================================================
--- /java/server/trunk/src/org/red5/server/net/udp/BasicHandler.java (revision 1726)
+++ /java/server/trunk/src/org/red5/server/net/udp/BasicHandler.java (revision 1728)
@@ -14,4 +14,35 @@
 import org.apache.mina.common.IoSession;
 
+import sun.misc.HexDumpEncoder;
+
+/**
+ *
+ * => client send to server
+ * <= server send to client
+ * << server broadcast
+ *
+ * Connecting to the server
+ *
+ * => byte(join)
+ * << byte(join) int(id)
+ * => byte(list)
+ * <= byte(list) int(count) int(id) int(id) ...
+ *
+ * Sending a message to all
+ *
+ * => byte(send) [..anything..]
+ * << byte(send) [..anything..]
+ *
+ * Server ping client to keep alive, every second
+ *
+ * <= byte(noop)
+ * => byte(noop)
+ *
+ * Timeouts (after 10s no reply)
+ *
+ * << byte(exit)
+ *
+ * @author luke
+ */
 public class BasicHandler extends IoHandlerAdapter {
 
@@ -21,11 +52,13 @@
 	static final int TIMEOUT = 10000;
 
-	static final byte NOOP = 0x01; // byte
-	static final byte LIST = 0x02; // byte, int count, int id, int id, ..
-	static final byte JOIN = 0x03; // byte, int id
-	static final byte SEND = 0x04; // byte, anything
-	static final byte EXIT = 0x05; // byte, int id
+	static final byte NOOP = 0x00;
+	static final byte JOIN = 0x01;
+	static final byte LIST = 0x02;
+	static final byte SEND = 0x03;
+	static final byte EXIT = 0x04;
 
-	final ByteBuffer NOOP_MSG = ByteBuffer.wrap(new byte[]{NOOP});
+	static final HexDumpEncoder dumper = new HexDumpEncoder();
+
+	final ByteBuffer NOOP_MSG = ByteBuffer.wrap(new byte[]{NOOP}).asReadOnlyBuffer();
 
 	protected Timer timer = new Timer("Timer", true);
@@ -47,17 +80,23 @@
 	public void messageReceived(IoSession session, Object message) throws Exception {
 		if(showInfo) log.info("Incomming: "+session.getRemoteAddress().toString());
+
 		ByteBuffer data = (ByteBuffer) message;
+
+		// IN HEX DUMP
+		log.info(dumper.encode(data.asReadOnlyBuffer().buf()));
+
 		final byte type = data.get();
 		data.position(0);
+
 		switch(type){
 		case NOOP:
-			echo(session, data);
-			break;
-		case LIST:
-			list(session);
+			// drop
 			break;
 		case JOIN:
 			sessions.add(session);
 			join(session);
+			break;
+		case LIST:
+			list(session);
 			break;
 		case SEND:
@@ -70,4 +109,5 @@
 			break;
 		default:
+			if(showInfo) log.info("Unknown (play echo): "+session.getRemoteAddress().toString());
 			echo(session, data);
 			break;
@@ -120,7 +160,5 @@
 	public void sessionCreated(IoSession session) throws Exception {
 		if(showInfo) log.info("Created: "+session.getRemoteAddress().toString());
-		sessions.add(session);
-		join(session);
-		list(session);
+		if(showInfo) log.info("Created: "+session.getRemoteAddress().toString());
 	}
 


Note:
Diffs are chopped if more than 25k.
This is to get past the limit on the mailing list.



More information about the Red5commits mailing list