mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
Тестовая команда "test start" для старта сервера netty
This commit is contained in:
parent
e16145cb6b
commit
4e739a74b5
3 changed files with 14 additions and 10 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
import ru.gravit.launchserver.socket.NettyServerSocketHandler;
|
||||
import ru.gravit.utils.HttpDownloader;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
|
@ -11,7 +12,7 @@ public class TestCommand extends Command {
|
|||
public TestCommand(LaunchServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
||||
NettyServerSocketHandler handler;
|
||||
@Override
|
||||
public String getArgsDescription() {
|
||||
return null;
|
||||
|
@ -25,8 +26,11 @@ public String getUsageDescription() {
|
|||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
verifyArgs(args,1);
|
||||
LogHelper.debug("start downloading");
|
||||
HttpDownloader downloader =new HttpDownloader(new URL(args[0]),"test.html");
|
||||
LogHelper.debug("end downloading");
|
||||
if(handler == null)
|
||||
handler = new NettyServerSocketHandler(server);
|
||||
if(args[0].equals("start"))
|
||||
{
|
||||
handler.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
import javax.net.ssl.*;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.nio.channels.Selector;
|
||||
|
@ -100,7 +101,7 @@ public SSLContext SSLContextInit() throws NoSuchAlgorithmException, Unrecoverabl
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
SSLContext sc = null;
|
||||
/*SSLContext sc = null;
|
||||
try {
|
||||
sc = SSLContextInit();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
|
@ -115,7 +116,7 @@ public void run() {
|
|||
e.printStackTrace();
|
||||
} catch (CertificateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
//System.setProperty( "javax.net.ssl.keyStore","keystore");
|
||||
//System.setProperty( "javax.net.ssl.keyStorePassword","PSP1000");
|
||||
try {
|
||||
|
@ -126,8 +127,8 @@ public void run() {
|
|||
e.printStackTrace();
|
||||
}
|
||||
LogHelper.info("Starting server socket thread");
|
||||
SSLEngine engine = sc.createSSLEngine();
|
||||
engine.setUseClientMode(false);
|
||||
//SSLEngine engine = sc.createSSLEngine();
|
||||
//engine.setUseClientMode(false);
|
||||
EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||
EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||
try {
|
||||
|
@ -149,7 +150,7 @@ public void initChannel(NioSocketChannel ch) throws Exception {
|
|||
pipeline.addLast(new WebSocketFrameHandler());
|
||||
}
|
||||
});
|
||||
ChannelFuture f = b.bind(server.config.getSocketAddress()).sync();
|
||||
ChannelFuture f = b.bind(new InetSocketAddress(9876)).sync(); //TEST ONLY!
|
||||
f.channel().closeFuture().sync();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -15,7 +15,6 @@ public class WebSocketFrameHandler extends SimpleChannelInboundHandler<WebSocket
|
|||
|
||||
protected void channelRead0(ChannelHandlerContext ctx, WebSocketFrame frame) throws Exception {
|
||||
// ping and pong frames already handled
|
||||
|
||||
if (frame instanceof TextWebSocketFrame) {
|
||||
// Send the uppercase string back.
|
||||
String request = ((TextWebSocketFrame) frame).text();
|
||||
|
|
Loading…
Reference in a new issue