2626
2727package com .yeetor ;
2828
29- import com .neovisionaries .ws .client .WebSocketException ;
3029import com .yeetor .adb .AdbServer ;
31- import com .yeetor .androidcontrol .client .RemoteClient ;
32- import com .yeetor .androidcontrol .server .LocalServer ;
33- import com .yeetor .androidcontrol .server .RemoteServer ;
3430import com .yeetor .server .AndroidControlServer ;
31+ import com .yeetor .util .JarTool ;
3532import org .apache .log4j .Logger ;
36- import java .security .InvalidParameterException ;
37-
3833
3934/**
4035 * Created by harry on 2017/4/15.
@@ -61,74 +56,5 @@ public static void main(String[] args) throws Exception {
6156
6257 AndroidControlServer server = new AndroidControlServer ();
6358 server .listen (6655 );
64-
65- try {
66- Config config = new Config (args );
67-
68- if (config .isClient ) {
69- new RemoteClient (config .ip , config .port , config .key , config .serialNumber );
70- } else {
71- if (config .isLocal ) {
72- new LocalServer (config .port ).start ();
73- } else {
74- new RemoteServer (config .port ).start ();
75- }
76- }
77- } catch (InvalidParameterException ex ) {
78- System .out .println ("localserver <port>: 启动本地服务器(p2p)\n remoteserver <port> 启动服务器 \n remoteclient <ip> <port> <key> [serialNumber] 启动客户端" );
79- System .exit (0 );
80- } catch (WebSocketException |InterruptedException e ) {
81- System .out .println ("启动服务器失败: " + e .getMessage ());
82- System .exit (0 );
83- } catch (Exception e ) {
84- e .printStackTrace ();
85- System .exit (0 );
86- }
87- }
88-
89- static class Config {
90- boolean isLocal = true ;
91- boolean isClient = false ;
92- String ip = "" ;
93- int port = 6655 ;
94- String serialNumber = "" ;
95- String key = "" ;
96-
97- Config (String [] args ) throws InvalidParameterException {
98- if (args .length > 0 ) {
99- if ("localserver" .equals (args [0 ])) {
100- isLocal = true ;
101- isClient = false ;
102- } else if ("remoteserver" .equals (args [0 ])) {
103- isLocal = false ;
104- isClient = false ;
105- } else {
106- isLocal = true ;
107- isClient = true ;
108- }
109- }
110-
111- if (isClient ) {
112- if (args .length == 4 ) {
113- ip = args [1 ];
114- port = Integer .parseInt (args [2 ]);
115- key = args [3 ];
116- } else if (args .length == 5 ) {
117- ip = args [1 ];
118- port = Integer .parseInt (args [2 ]);
119- key = args [3 ];
120- serialNumber = args [4 ];
121- } else {
122- throw new InvalidParameterException ("参数不正确" );
123- }
124- } else {
125- if (args .length == 2 ) {
126- port = Integer .parseInt (args [1 ]);
127- } else {
128- throw new InvalidParameterException ("参数不正确" );
129- }
130- }
131- }
13259 }
133-
13460}
0 commit comments