readme 更新 2023年3月14日11:37:43
parent
3a04e1c0de
commit
60da5a5fe8
|
|
@ -148,7 +148,7 @@
|
||||||
|
|
||||||
###### 8.3.1 javafx 实现
|
###### 8.3.1 javafx 实现
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
###### 8.3.2 html 实现
|
###### 8.3.2 html 实现
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,28 +102,15 @@ public class SSHConnectionController {
|
||||||
private WebSocketClient webSocketClient;
|
private WebSocketClient webSocketClient;
|
||||||
private SSHService sshService;
|
private SSHService sshService;
|
||||||
|
|
||||||
private SimpleObjectProperty<String> cmd = new SimpleObjectProperty<>();
|
|
||||||
|
|
||||||
private boolean isConnection = false;
|
private boolean isConnection = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* 用于与Javascript引擎通信。
|
|
||||||
*/
|
|
||||||
private JSObject javascriptConnector;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用于从Javascript引擎进行通信。
|
|
||||||
*/
|
|
||||||
private JavaConnector javaConnector = new JavaConnector();
|
|
||||||
;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
// username.setText("root");
|
username.setText("root");
|
||||||
// password.setText("root");
|
password.setText("root");
|
||||||
// host.setText("192.168.52.165");
|
host.setText("192.168.52.165");
|
||||||
// port.setText("22");
|
port.setText("22");
|
||||||
|
|
||||||
message_list.addListener((ListChangeListener<String>) c -> {
|
message_list.addListener((ListChangeListener<String>) c -> {
|
||||||
while (c.next()) {
|
while (c.next()) {
|
||||||
|
|
@ -177,7 +164,7 @@ public class SSHConnectionController {
|
||||||
// } catch (InterruptedException e) {
|
// } catch (InterruptedException e) {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
//发送连接信息
|
// 发送连接信息
|
||||||
// SSHData ssh_data = create_ssh_data(command.getText(), SSHData.Type.connect);
|
// SSHData ssh_data = create_ssh_data(command.getText(), SSHData.Type.connect);
|
||||||
// webSocketClient.send(toString(ssh_data));
|
// webSocketClient.send(toString(ssh_data));
|
||||||
|
|
||||||
|
|
@ -213,7 +200,6 @@ public class SSHConnectionController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) {
|
public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) {
|
||||||
add_msg("WebSocketServer:onOpen--------------------------------------------");
|
|
||||||
sshService.initConnection(webSocket, uuid.getValue());
|
sshService.initConnection(webSocket, uuid.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -225,7 +211,6 @@ public class SSHConnectionController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(WebSocket webSocket, String s) {
|
public void onMessage(WebSocket webSocket, String s) {
|
||||||
add_msg("WebSocketServer:onMessage---" + s);
|
|
||||||
sshService.recvHandle(s, webSocket, uuid.getValue());
|
sshService.recvHandle(s, webSocket, uuid.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,14 +226,6 @@ public class SSHConnectionController {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public class JavaConnector {
|
|
||||||
|
|
||||||
public void ssh_info() {
|
|
||||||
SSHData ssh_data = create_ssh_data("", SSHData.Type.connect);
|
|
||||||
javascriptConnector.call(JSON.toJSONString(ssh_data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void load_page_client() {
|
public void load_page_client() {
|
||||||
WebEngine webEngine = webView.getEngine();
|
WebEngine webEngine = webView.getEngine();
|
||||||
TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("templates", TemplateConfig.ResourceMode.CLASSPATH));
|
TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("templates", TemplateConfig.ResourceMode.CLASSPATH));
|
||||||
|
|
@ -305,10 +282,7 @@ public class SSHConnectionController {
|
||||||
//收到服务端消息时触发
|
//收到服务端消息时触发
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(String message) {
|
public void onMessage(String message) {
|
||||||
String[] s = message.split(" ");
|
add_msg(message);
|
||||||
for (String s1 : s) {
|
|
||||||
add_msg(s1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//和服务端断开连接时触发
|
//和服务端断开连接时触发
|
||||||
|
|
@ -330,14 +304,13 @@ public class SSHConnectionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void add_msg(String msg) {
|
public static void add_msg(String msg) {
|
||||||
// message_list.add(msg);
|
message_list.add(msg);
|
||||||
// message_list.add("------------------------------------------------------------------->");
|
message_list.add(System.lineSeparator());
|
||||||
// message_list.add(System.lineSeparator());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void receive(String msg) {
|
public void receive(String msg) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
// this.show_result.setText(msg);
|
// this.show_result.setText(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
<?import javafx.scene.control.TextField?>
|
<?import javafx.scene.control.TextField?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.web.WebView?>
|
<?import javafx.scene.web.WebView?>
|
||||||
|
<?import javafx.scene.control.TextArea?>
|
||||||
|
|
||||||
<AnchorPane prefHeight="649.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.zhangmeng.tools.controller.SSHConnectionController">
|
<AnchorPane prefHeight="649.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.zhangmeng.tools.controller.SSHConnectionController">
|
||||||
<children>
|
<children>
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
Loading…
Reference in New Issue