|
7 | 7 |
|
8 | 8 | package org.red5.client.net.rtmps; |
9 | 9 |
|
| 10 | +import java.net.InetSocketAddress; |
| 11 | + |
10 | 12 | import javax.net.ssl.SSLContext; |
11 | 13 |
|
| 14 | +import org.apache.mina.core.future.IoFuture; |
| 15 | +import org.apache.mina.core.future.IoFutureListener; |
12 | 16 | import org.apache.mina.core.session.IoSession; |
13 | 17 | import org.apache.mina.filter.ssl.SslFilter; |
| 18 | +import org.apache.mina.transport.socket.nio.NioSocketConnector; |
14 | 19 | import org.red5.client.net.rtmp.RTMPClient; |
15 | 20 | import org.red5.client.net.rtmp.RTMPMinaIoHandler; |
16 | 21 | import org.red5.client.net.ssl.BogusSslContextFactory; |
@@ -56,6 +61,34 @@ public RTMPSClient() { |
56 | 61 | ioHandler.setHandler(this); |
57 | 62 | } |
58 | 63 |
|
| 64 | + @SuppressWarnings({ "rawtypes" }) |
| 65 | + @Override |
| 66 | + protected void startConnector(String server, int port) { |
| 67 | + socketConnector = new NioSocketConnector(); |
| 68 | + socketConnector.setHandler(ioHandler); |
| 69 | + future = socketConnector.connect(new InetSocketAddress(server, port)); |
| 70 | + future.addListener(new IoFutureListener() { |
| 71 | + @Override |
| 72 | + public void operationComplete(IoFuture future) { |
| 73 | + try { |
| 74 | + // will throw RuntimeException after connection error |
| 75 | + future.getSession(); |
| 76 | + } catch (Throwable e) { |
| 77 | + //if there isn't an ClientExceptionHandler set, a |
| 78 | + //RuntimeException may be thrown in handleException |
| 79 | + handleException(e); |
| 80 | + } |
| 81 | + } |
| 82 | + }); |
| 83 | + // Do the close requesting that the pending messages are sent before |
| 84 | + // the session is closed |
| 85 | + //future.getSession().close(false); |
| 86 | + // Now wait for the close to be completed |
| 87 | + future.awaitUninterruptibly(CONNECTOR_WORKER_TIMEOUT); |
| 88 | + // We can now dispose the connector |
| 89 | + //socketConnector.dispose(); |
| 90 | + } |
| 91 | + |
59 | 92 | /** |
60 | 93 | * Password used to access the keystore file. |
61 | 94 | * |
|
0 commit comments