mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FIX] Еще немного магии с портами
This commit is contained in:
parent
686ffa6371
commit
8873d6ec90
1 changed files with 9 additions and 2 deletions
|
@ -28,6 +28,7 @@ public abstract class ClientJSONPoint {
|
|||
protected WebSocketClientHandler webSocketClientHandler;
|
||||
protected Bootstrap bootstrap = new Bootstrap();
|
||||
protected boolean ssl = false;
|
||||
protected int port = -1;
|
||||
public boolean isClosed;
|
||||
|
||||
public ClientJSONPoint(final String uri) throws SSLException {
|
||||
|
@ -44,6 +45,12 @@ public ClientJSONPoint(URI uri) throws SSLException {
|
|||
{
|
||||
ssl = true;
|
||||
}
|
||||
if(uri.getPort() == -1)
|
||||
{
|
||||
if("ws".equals(protocol)) port = 80;
|
||||
else port = 443;
|
||||
}
|
||||
else port = uri.getPort();
|
||||
final SslContext sslCtx;
|
||||
if (ssl) {
|
||||
sslCtx = SslContextBuilder.forClient().build();
|
||||
|
@ -55,7 +62,7 @@ public ClientJSONPoint(URI uri) throws SSLException {
|
|||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
ChannelPipeline pipeline = ch.pipeline();
|
||||
if (sslCtx != null) {
|
||||
pipeline.addLast(sslCtx.newHandler(ch.alloc(), uri.getHost(), 443));
|
||||
pipeline.addLast(sslCtx.newHandler(ch.alloc(), uri.getHost(), port));
|
||||
}
|
||||
pipeline.addLast("http-codec", new HttpClientCodec());
|
||||
pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
|
||||
|
@ -70,7 +77,7 @@ public void open() throws Exception {
|
|||
new WebSocketClientHandler(
|
||||
WebSocketClientHandshakerFactory.newHandshaker(
|
||||
uri, WebSocketVersion.V13, null, false, EmptyHttpHeaders.INSTANCE, 1280000), this);
|
||||
ch = bootstrap.connect(uri.getHost(), ssl ? 443 : uri.getPort()).sync().channel();
|
||||
ch = bootstrap.connect(uri.getHost(), port).sync().channel();
|
||||
webSocketClientHandler.handshakeFuture().sync();
|
||||
}
|
||||
public ChannelFuture send(String text)
|
||||
|
|
Loading…
Reference in a new issue