Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 1.10 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How can connect to SSL in JAVA with websocket and socket.io?
  2. client = SocketChannel.open(remote);
  3.   client.configureBlocking(false);
  4.   //client.connect(remote);
  5.  
  6.   selector = Selector.open();
  7.   this.conn = new WebSocket(client, new LinkedBlockingQueue<ByteBuffer>(), this);
  8.   client.register(selector, SelectionKey.OP_READ);
  9.  
  10.     try {
  11.    sslClient = new SSLClient(keyStore, storepass.toCharArray(), client);
  12.    sslClient.beginHandShake();
  13.         startClient()
  14.  
  15.  
  16. } catch (Exception e) {
  17.    e.printStackTrace();
  18. }
  19.        
  20. public void startClient()
  21. {
  22.     try
  23.     {
  24.         while(true)
  25.         {
  26.             if(selector.select() <= 0)
  27.             {
  28.                 continue;
  29.             }
  30.  
  31.             Iterator<SelectionKey> it = selector.selectedKeys().iterator();
  32.  
  33.             while(it.hasNext())
  34.             {
  35.                 SelectionKey key = (SelectionKey)it.next();
  36.                 Log.e("key","key");
  37.                 if(key.isReadable())
  38.                 {
  39.                     read(key);
  40.                 }
  41.                 it.remove();
  42.             }              
  43.         }
  44.     }
  45.     catch(Exception e)
  46.     {
  47.  
  48.     }
  49. }