package com.simplegame.protocol;

import org.junit.Test;

import com.alibaba.fastjson.JSONArray;
import com.simplegame.protocol.codec.ClientListener;
import com.simplegame.protocol.codec.ServerListener;
import com.simplegame.protocol.proto.Message.Request;
import com.simplegame.protocol.utils.SerializableUtil;

/**
 *
 * @Author zeusgooogle@gmail.com
 * @sine   2015年5月4日 上午11:52:53
 *
 */

public class ClientLinstenerTest extends BasicTest {

	@Test
	public void start() throws InterruptedException {
		ClientListener client = ctx.getBean(ClientListener.class);
		client.start();
		
		/**
		 * Message Body 
		 * 0: command 		Not Null 
		 * 1: data 			Not Null 
		 * 2: sessionId 
		 * 3: roleId
		 * 4: accountId 
		 * 5: stageId 
		 * 6: token
		 * 
		 */
		
		//Data
		JSONArray array = new JSONArray();
		array.add("1001");
		
		JSONArray data = new JSONArray();
		data.add(3);
		data.add("hellow");
		data.add(true);
		array.add(data.toArray());
		
		Request.Builder builder = Request.newBuilder();
		builder.setCommand("10001")
		       .setData(array.toJSONString());
		
		client.sendMessage(builder);
		
		Thread.sleep(30000);
	}
	
}

@@ -27,16 +27,42 @@
 tocol;%0A%0A
+import java.util.Arrays;%0A%0A
 import o
@@ -486,21 +486,275 @@
 ic void 
-start
+proto() %7B%0A%09%09//Data%0A%09%09%0A%09%09Request.Builder builder = Request.newBuilder();%0A%09%09builder.setCommand(%2210001%22)%0A%09%09       .setData(%22123456%22);%09%09%0A%09%09%0A%09%09byte%5B%5D bytes = builder.build().toByteArray();%0A%09%09System.out.println( Arrays.toString(bytes) );%0A%09%7D%0A%09%0A%09@Test%0A%09public void in
 () throw
@@ -1101,18 +1101,516 @@
 dd(%22
-1001%22);%0A%09%09
+vip1%22); //userId%0A%09%09array.add(%221%22);    //serverId%0A%09%09%0A%09%09/**%0A%09%09 * %E4%B8%AD%E5%BF%83%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%94%9F%E6%88%90%0A%09%09 */%0A%09%09array.add(System.currentTimeMillis() + %22%22); //timestamp%0A%09%09array.add(%22signXXX%22);%09//sign%0A%09%09%0A%09%09Request.Builder builder = Request.newBuilder();%0A%09%09builder.setCommand(%2210001%22)%0A%09%09       .setData(array.toJSONString());%0A%09%09%0A%09%09client.sendMessage(builder);%0A%09%09%0A%09%09Thread.sleep(30000);%0A%09%7D%0A%09%0A%09@Test%0A%09public void createRole() throws InterruptedException %7B%0A%09%09ClientListener client = ctx.getBean(ClientListener.class);%0A%09%09client.start();%0A%09%09%0A%09%09//Data
 %0A%09%09J
@@ -1618,20 +1618,21 @@
 ONArray 
-data
+array
  = new J
@@ -1649,89 +1649,252 @@
 ;%0A%09%09
-data.add(3);%0A%09%09data.add(%22hellow%22);%0A%09%09data.add(true);%0A%09%09array.add(data.toArray());
+array.add(%22vip1%22); %09%09//userId%0A%09%09array.add(%221%22);    %09%09//serverId%0A%09%09array.add(%22%E6%88%91%E6%98%AFVIP%22); %09//name%0A%09%09array.add(%22A%22); %09%09//job A, B, C, D%0A%09%09array.add(1); %09%09%09//sex  1:man, 0: woman%0A%09%09array.add(%22B%22);%09%09%09//face A, B, C, D%0A%09%09array.add(%22qzone%22);%09%09//platform
 %0A%09%09%0A
@@ -1961,33 +1961,33 @@
 setCommand(%221000
-1
+2
 %22)%0A%09%09       .set

add create role test