MCPcopy Index your code
hub / github.com/arduino/Arduino / tryConnect

Method tryConnect

app/src/processing/app/NetworkMonitor.java:78–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76 }
77
78 private void tryConnect() throws JSchException, IOException {
79 connectionAttempts++;
80
81 if (connectionAttempts > 1) {
82 try {
83 Thread.sleep(2000);
84 } catch (InterruptedException e) {
85 // ignored
86 }
87 }
88
89 if (!session.isConnected()) {
90 return;
91 }
92 channel = session.openChannel("exec");
93 ((ChannelExec) channel).setCommand("telnet localhost 6571");
94
95 InputStream inputStream = channel.getInputStream();
96 InputStream errStream = ((ChannelExec) channel).getErrStream();
97
98 channel.connect();
99
100 inputConsumer = new MessageSiphon(inputStream, this);
101 new MessageSiphon(errStream, this);
102
103 if (connectionAttempts > 1) {
104 SwingUtilities.invokeLater(new Runnable() {
105
106 @Override
107 public void run() {
108 try {
109 Thread.sleep(1000);
110 } catch (InterruptedException e) {
111 // ignore
112 }
113 if (channel.isConnected()) {
114 NetworkMonitor.this.message(tr("connected!") + '\n');
115 }
116 }
117
118 });
119 }
120 }
121
122 @Override
123 public synchronized void message(String s) {

Callers 2

openMethod · 0.95
runMethod · 0.80

Calls 3

sleepMethod · 0.80
getInputStreamMethod · 0.80
connectMethod · 0.80

Tested by

no test coverage detected