Commit e1fa6f57 authored by 神楽坂玲奈's avatar 神楽坂玲奈

fix

parent 6cfdb64d
Pipeline #16054 failed with stages
in 1 minute and 6 seconds
...@@ -7,11 +7,11 @@ import { api } from './Api'; ...@@ -7,11 +7,11 @@ import { api } from './Api';
import express from 'express'; import express from 'express';
import path from 'path'; import path from 'path';
// http // http
const app = express(); const app = express();
app.use(express.static(path.join(__dirname, 'public'))); app.use(express.static(path.join(__dirname, 'public')));
app.use('/', api); app.use('/', api);
app.listen(config.port);
// udp routing protocol // udp routing protocol
const socket = dgram const socket = dgram
...@@ -20,17 +20,16 @@ const socket = dgram ...@@ -20,17 +20,16 @@ const socket = dgram
const address = socket.address(); const address = socket.address();
console.log(`listening ${address.address}:${address.port}`); console.log(`listening ${address.address}:${address.port}`);
}) })
.on('message', function(message, rinfo) { .on('message', function (message, rinfo) {
try { try {
const hello: UploadMessage = JSON.parse(message.toString()); const hello: UploadMessage = JSON.parse(message.toString());
assert(hello.id); assert(hello.id);
const router: Router = Router.all.find(r => r.id === hello.id)!; const router: Router = Router.all.find((r) => r.id === hello.id)!;
assert(router); assert(router);
router.rinfo = rinfo; router.rinfo = rinfo;
router.onMessage(hello); router.onMessage(hello);
} catch (e) { } catch (e) {
console.warn(e); console.warn(e);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment