com.pusher.java_websocket.client.AbstractClientProxyChannel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-websocket Show documentation
Show all versions of java-websocket Show documentation
The Pusher fork of TooTallNate/Java-Websocket
The newest version!
package com.pusher.java_websocket.client;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import com.pusher.java_websocket.AbstractWrappedByteChannel;
public abstract class AbstractClientProxyChannel extends AbstractWrappedByteChannel {
protected final ByteBuffer proxyHandshake;
/**
* @param towrap
* The channel to the proxy server
**/
public AbstractClientProxyChannel( ByteChannel towrap ) {
super( towrap );
try {
proxyHandshake = ByteBuffer.wrap( buildHandShake().getBytes( "ASCII" ) );
} catch ( UnsupportedEncodingException e ) {
throw new RuntimeException( e );
}
}
@Override
public int write( ByteBuffer src ) throws IOException {
if( !proxyHandshake.hasRemaining() ) {
return super.write( src );
} else {
return super.write( proxyHandshake );
}
}
public abstract String buildHandShake();
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy