/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.deephacks.westty.example;

import java.io.File;
import java.net.InetSocketAddress;

import org.deephacks.westty.example.CreateMessages.CreateRequest;
import org.deephacks.westty.example.DeleteMessages.DeleteRequest;
import org.deephacks.westty.protobuf.WesttyProtobufClient;
import org.deephacks.westty.protobuf.ProtobufSerializer;

public class ExampleProtobuf {
    public static void main(String[] args) throws Exception {
        ProtobufSerializer serializer = new ProtobufSerializer();
        serializer.register(new File("src/main/resources/META-INF/create.desc"));
        serializer.register(new File("src/main/resources/META-INF/delete.desc"));
        WesttyProtobufClient client = new WesttyProtobufClient(new InetSocketAddress(7777), serializer);
        client.connect();
        CreateRequest create = CreateRequest.newBuilder().setName("name").setPassword("pw").build();
        DeleteRequest delete = DeleteRequest.newBuilder().setName("name").build();
        client.write(create).awaitUninterruptibly();
        client.write(delete).awaitUninterruptibly();
        Thread.sleep(2000);
        client.disconnect();
        Thread.sleep(2000);
        client = new WesttyProtobufClient(new InetSocketAddress(7777), serializer);
        client.connect();
        client.write(create).awaitUninterruptibly();
        client.write(delete).awaitUninterruptibly();
        Thread.sleep(2000);
        client.disconnect();
    }
}

@@ -820,30 +820,24 @@
 rotobuf.
-Westty
 Protobuf
 Client;%0A
@@ -828,22 +828,26 @@
 Protobuf
-Client
+Serializer
 ;%0Aimport
@@ -873,32 +873,38 @@
 ty.protobuf.
+Westty
 Protobuf
 Serializer;%0A
@@ -891,26 +891,22 @@
 Protobuf
-Serializer
+Client
 ;%0A%0Apubli
@@ -1215,32 +1215,167 @@
 delete.desc%22));%0A
+        run(serializer);%0A        run(serializer);%0A%0A    %7D%0A%0A    public static void run(ProtobufSerializer serializer) throws Exception %7B%0A
         WesttyPr
@@ -1441,32 +1441,48 @@
 etAddress(7777),
+%0A               
  serializer);%0A  
@@ -1497,32 +1497,77 @@
 ient.connect();%0A
+        for (int i = 0; i %3C 1000; i++) %7B%0A    
         CreateRe
@@ -1641,16 +1641,37 @@
 rd(%22pw%22)
+%0A                    
 .build()
@@ -1680,16 +1680,20 @@
         
+    
 DeleteRe
@@ -1759,32 +1759,36 @@
 uild();%0A        
+    
 client.write(cre
@@ -1816,32 +1816,36 @@
 ibly();%0A        
+    
 client.write(del
@@ -1881,35 +1881,17 @@
         
-Thread.sleep(2000);
+%7D
 %0A       
@@ -1904,32 +1904,33 @@
 t.disconnect();%0A
+%0A
         Thread.s
@@ -1953,260 +1953,29 @@
     
-client = new WesttyProtobufClient(new InetSocketAddress(7777), serializer);%0A        client.connect();%0A        client.write(create).awaitUninterruptibly();%0A        client.write(delete).awaitUninterruptibly();%0A        Thread.sleep(2000);%0A        client.d
+System.out.println(%22D
 isco
@@ -1975,24 +1975,25 @@
 (%22Disconnect
-(
+%22
 );%0A
+%0A
     %7D%0A%7D%0A

Change example to put a little load on westty protobuf endpoint