Sockets integration with service
This commit is contained in:
@@ -10,36 +10,36 @@ import JSONStream from "JSONStream";
|
|||||||
import oboe from "oboe";
|
import oboe from "oboe";
|
||||||
import { io } from "socket.io-client";
|
import { io } from "socket.io-client";
|
||||||
|
|
||||||
const socket = io("ws://localhost:3853/", {});
|
const socket = io("ws://localhost:3000/", {
|
||||||
|
reconnectionDelayMax: 10000,
|
||||||
|
});
|
||||||
|
|
||||||
socket.on("connect", () => {
|
socket.on("connect", () => {
|
||||||
console.log(`connect ${socket.id}`);
|
console.log(`connect ${socket.id}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("disconnect", () => {
|
socket.on("disconnect", () => {
|
||||||
console.log(`disconnect`);
|
console.log(`disconnect`);
|
||||||
});
|
});
|
||||||
|
|
||||||
setInterval(() => {
|
|
||||||
const start = Date.now();
|
|
||||||
socket.emit("ping", () => {
|
|
||||||
console.log(`pong (latency: ${Date.now() - start} ms)`);
|
|
||||||
});
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
router.route("/getComicCovers").post(async (req: Request, res: Response) => {
|
router.route("/getComicCovers").post(async (req: Request, res: Response) => {
|
||||||
typeof req.body.extractionOptions === "object"
|
typeof req.body.extractionOptions === "object"
|
||||||
? req.body.extractionOptions
|
? req.body.extractionOptions
|
||||||
: {};
|
: {};
|
||||||
request({
|
const { extractionOptions, walkedFolders } = req.body;
|
||||||
url: "http://localhost:3000/api/import/getComicCovers",
|
socket.emit("call", {
|
||||||
method: "POST",
|
action: "getComicCovers",
|
||||||
json: true,
|
params: {
|
||||||
body: {
|
extractionOptions,
|
||||||
extractionOptions: req.body.extractionOptions,
|
walkedFolders,
|
||||||
walkedFolders: req.body.walkedFolders,
|
|
||||||
},
|
},
|
||||||
}).pipe(res);
|
opts: { garam: "pasha" },
|
||||||
|
});
|
||||||
|
socket.on("comicBookCoverMetadata", (done) => {
|
||||||
|
console.log(done);
|
||||||
|
});
|
||||||
|
// socket.on("hello", (done) => done);
|
||||||
|
res.sendStatus(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
router.route("/walkFolder").post(async (req: Request, res: Response) => {
|
router.route("/walkFolder").post(async (req: Request, res: Response) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user