public void actionPerformed()

in fastmodel-driver/fastmodel-driver-server/src/main/java/com/aliyun/fastmodel/driver/server/websocket/FastModelWebSocketClient.java [193:245]


    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == connect) {
            cc = new WebSocketClient(new URI(uriField.getText())) {
                @Override
                public void onOpen(ServerHandshake handshakedata) {
                    ta.append("You are connected to Server:" + getURI() + "\n");
                    ta.setCaretPosition(ta.getDocument().getLength());
                }

                @Override
                public void onMessage(String message) {
                    ta.append("got:" + message + "\n");
                    ta.setCaretPosition(ta.getDocument().getLength());
                    try {
                        Message object = JSON.parseObject(message, Message.class);
                        if (object.getAction() == MessageAction.RENDER) {
                            render(object);
                        }
                    } catch (Exception exception) {

                    }
                }

                @Override
                public void onClose(int code, String reason, boolean remote) {
                    ta.append(
                        "You have been disconnected from: " + getURI() + "; Code: " + code + " " + reason
                            + "\n");
                    ta.setCaretPosition(ta.getDocument().getLength());
                    connect.setEnabled(true);
                    uriField.setEditable(true);
                    close.setEnabled(false);
                }

                @Override
                public void onError(Exception ex) {
                    ta.append("Exception occurred ...\n" + ex + "\n");
                    ta.setCaretPosition(ta.getDocument().getLength());
                    ex.printStackTrace();
                    connect.setEnabled(true);
                    uriField.setEditable(true);
                    close.setEnabled(false);
                }
            };

            close.setEnabled(true);
            connect.setEnabled(false);
            uriField.setEditable(false);
            cc.connect();
        } else if (e.getSource() == close) {
            cc.close();
        }
    }