<mailto:
abhinav.rajan0@gmail.com>> wrote:
Hi Thomas,
Please find below the test client code. I'm just printing the data
sent by the server.
Thank you so much for looking into this.
--Abhinav
import java.io.File;
import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.npn.
NextProtoNego;
import org.eclipse.jetty.spdy.api.
DataInfo;
import org.eclipse.jetty.spdy.api.
SPDY;
import org.eclipse.jetty.spdy.api.
Session;
import org.eclipse.jetty.spdy.api.
Stream;
import org.eclipse.jetty.spdy.api.
StreamFrameListener;
import org.eclipse.jetty.spdy.api.
StringDataInfo;
import org.eclipse.jetty.spdy.api.
SynInfo;
import org.eclipse.jetty.spdy.client.
SPDYClient;
import org.eclipse.jetty.util.Fields;
/**
* Put
<code>-Xbootclasspath/p:lib/
spdy/npn-boot-1.1.1.v20121030.
jar</code> as
* vmarg.
*/
public class TestClient {
/**
* Main method.
* @param args
* @throws Exception
*/
private static final String keystoreFile =
"/Users/abhinavsunderrajan/
Documents/workspace/
PlatformCore/src/test/
resources/certificates/dev-
test-client/dev-test-client.
jks";
private static final File keystorePasswordFile = new File(
"/Users/abhinavsunderrajan/
Documents/workspace/
PlatformCore/src/test/
resources/certificates/dev-
test-client/store-password");
private static final String serverCertificateFile =
"/Users/abhinavsunderrajan/
Documents/workspace/
PlatformCore/src/test/
resources/certificates/dev-
test-platform/dev-test-
platform.cer";
private static final String caCertificateFile =
"/Users/abhinavsunderrajan/
Documents/workspace/
PlatformCore/src/test/
resources/certificates/
platformCA/cacert.pem";
public static void main(final String[] args) throws Exception {
try {
// create client
NextProtoNego.debug = true;
SPDYClient.Factory clientFactory = new SPDYClient.Factory(
SecurityHelper.
getSSLContextFactory(
keystoreFile,
keystorePasswordFile, serverCertificateFile,
caCertificateFile));
clientFactory.start();
SPDYClient client = clientFactory.newSPDYClient(
SPDY.V3);
System.out.println("Trying to get a session with the
server....");
// create a session to the server running on localhost
port 8181
Session session = client.connect(
new InetSocketAddress("localhost", 8181), null).get(10,
TimeUnit.SECONDS);
// this listener receives data from the server and prints it
StreamFrameListener streamListener = new
StreamFrameListener.Adapter() {
public void onData(final Stream stream, final DataInfo
dataInfo) {
// Data received from server
String content = dataInfo.asString("UTF-8", true);
System.out.println("SPDY content: " + content);
}
};
// Start a new session, and configure the stream listener
final Stream stream = session.syn(new SynInfo(new
Fields(), false),
streamListener).
getAssociatedStream();
stream.data(new StringDataInfo("hello platform", false));
} catch (Exception e) {
e.printStackTrace();
}
}
}
On Tue, Feb 12, 2013 at 4:41 PM, Thomas Becker <
tbecker@xxxxxxxxxxx