Socket.js 355 B

123456789101112131415161718192021222324
  1. 'use strict'
  2. var net = require('net');
  3. var r2mConsts = require('./Header.js');
  4. class R2m_Socket {
  5. constructor(host, port) {
  6. this.host = host || 'localhost';
  7. this.port = port || 9090;
  8. }
  9. open() {
  10. if (!this.client) {
  11. this.client = net.connect({port:this.port, host:this.host});
  12. }
  13. return this.client;
  14. }
  15. }
  16. module.exports = R2m_Socket;