Search in sources :

Example 1 with BaseElement

use of streamer.BaseElement in project cloudstack by apache.

the class AprSocketWrapperImpl method main.

/**
     * Example.
     */
public static void main(String[] args) {
    try {
        System.setProperty("streamer.Link.debug", "true");
        System.setProperty("streamer.Element.debug", "true");
        System.setProperty("rdpclient.MockServer.debug", "true");
        Pipeline pipeline = new PipelineImpl("echo client");
        AprSocketWrapperImpl socketWrapper = new AprSocketWrapperImpl("socket", null);
        pipeline.add(socketWrapper);
        pipeline.add(new BaseElement("echo"));
        // To decouple input and output
        pipeline.add(new Queue("queue"));
        pipeline.link("socket", "echo", "queue", "socket");
        final byte[] mockData = new byte[] { 0x01, 0x02, 0x03 };
        MockServer server = new MockServer(new Packet[] { new Packet("Server hello") {

            {
                type = SERVER;
                data = mockData;
            }
        }, new Packet("Client hello") {

            {
                type = CLIENT;
                data = mockData;
            }
        }, new Packet("Server hello") {

            {
                type = SERVER;
                data = mockData;
            }
        }, new Packet("Client hello") {

            {
                type = CLIENT;
                data = mockData;
            }
        } });
        server.start();
        InetSocketAddress address = server.getAddress();
        socketWrapper.connect(address);
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}
Also used : BaseElement(streamer.BaseElement) Packet(streamer.debug.MockServer.Packet) PipelineImpl(streamer.PipelineImpl) MockServer(streamer.debug.MockServer) InetSocketAddress(java.net.InetSocketAddress) Queue(streamer.Queue) IOException(java.io.IOException) Pipeline(streamer.Pipeline)

Aggregations

IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 BaseElement (streamer.BaseElement)1 Pipeline (streamer.Pipeline)1 PipelineImpl (streamer.PipelineImpl)1 Queue (streamer.Queue)1 MockServer (streamer.debug.MockServer)1 Packet (streamer.debug.MockServer.Packet)1