zqn пре 5 година
родитељ
комит
6798e7b093
3 измењених фајлова са 19 додато и 0 уклоњено
  1. 11 0
      app/controller/v1/example.js
  2. 2 0
      app/router/example.js
  3. 6 0
      app/service/socket.js

+ 11 - 0
app/controller/v1/example.js

@@ -64,6 +64,17 @@ class ExampleController extends BaseController {
 
     self.sendData(uploadRes);
   }
+
+  async getWsUrl() {
+    const self = this;
+    const { service } = this;
+    const data = {};
+
+    const addr = await service.socket.getWsUrl();
+    data.url = addr;
+
+    self.sendSuccess(data);
+  }
 }
 
 module.exports = ExampleController;

+ 2 - 0
app/router/example.js

@@ -9,4 +9,6 @@ module.exports = app => {
   router.post('/api/v1/example/openLocalDir', controller.v1.example.openLocalDir);
   // upload file
   router.post('/api/v1/example/uploadFile', controller.v1.example.uploadFile);
+  // get ws url
+  router.post('/api/v1/example/getWsUrl', controller.v1.example.getWsUrl);
 };

+ 6 - 0
app/service/socket.js

@@ -25,6 +25,12 @@ class SocketService extends BaseService {
     });
   }
 
+  async getWsUrl () {
+    const port = this.service.storage.getElectronIPCPort();
+    const url  = 'http://localhost:' + port;
+
+    return url;
+  }
 }
 
 module.exports = SocketService;