forward events from STP

stable
Bronwen 2020-11-18 12:02:58 -05:00
parent b1e0cf7ddd
commit 35df090d17
2 changed files with 11 additions and 2 deletions

View File

@ -63,6 +63,8 @@ class STPSocket extends EventEmitter {
else this.tcpSocket.on('connect', this.handshake.bind(this)); else this.tcpSocket.on('connect', this.handshake.bind(this));
this.tcpSocket.on('data', this.data.bind(this)); this.tcpSocket.on('data', this.data.bind(this));
this.tcpSocket.on('error', (...args) => this.emit('error', ...args));
this.tcpSocket.on('close', (...args) => this.emit('close', ...args));
} }
data(evt) { data(evt) {

View File

@ -22,6 +22,11 @@ let client = null;
client = null; client = null;
setTimeout(tryConnect, 1000); setTimeout(tryConnect, 1000);
}); });
client.on('close', () => {
log.error(`connection closed on ${config.addresses.relay}`)
client = null;
setTimeout(tryConnect, 1000);
});
client.on('data', (data) => { client.on('data', (data) => {
log.debug(data.toString()); log.debug(data.toString());
}) })
@ -55,10 +60,12 @@ app.get('/', (req, res) => {
<td><pre>${client.remoteAddress}</pre></td> <td><pre>${client.remoteAddress}</pre></td>
<td><pre>${client.remoteIdentity}</pre></td> <td><pre>${client.remoteIdentity}</pre></td>
</tr> </tr>
`)} `).join('')}
</table> </table>
`); `);
}) });
// app.post
app.listen(9999); app.listen(9999);