If you think the Android project SimplePushDemoApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package org.java_websocket.server;
import java.io.IOException;
import java.net.Socket;
import java.nio.channels.ByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
//fromwww.java2s.comimport javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import org.java_websocket.SSLSocketChannel2;
import org.java_websocket.WebSocketAdapter;
import org.java_websocket.WebSocketImpl;
import org.java_websocket.drafts.Draft;
publicclass DefaultSSLWebSocketServerFactory implements WebSocketServer.WebSocketServerFactory {
protected SSLContext sslcontext;
protected ExecutorService exec;
public DefaultSSLWebSocketServerFactory( SSLContext sslContext ) {
this( sslContext, Executors.newSingleThreadScheduledExecutor() );
}
public DefaultSSLWebSocketServerFactory( SSLContext sslContext , ExecutorService exec ) {
if( sslContext == null || exec == null )
thrownew IllegalArgumentException();
this.sslcontext = sslContext;
this.exec = exec;
}
@Override
public ByteChannel wrapChannel( SocketChannel channel, SelectionKey key ) throws IOException {
SSLEngine e = sslcontext.createSSLEngine();
e.setUseClientMode( false );
returnnew SSLSocketChannel2( channel, e, exec, key );
}
@Override
public WebSocketImpl createWebSocket( WebSocketAdapter a, Draft d, Socket c ) {
returnnew WebSocketImpl( a, d );
}
@Override
public WebSocketImpl createWebSocket( WebSocketAdapter a, List<Draft> d, Socket s ) {
returnnew WebSocketImpl( a, d );
}
}