Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14d4997
commit b25e728
Showing
10 changed files
with
77 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"target": "es2022", | ||
"module": "nodenext", | ||
"moduleResolution": "nodenext" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { io } from "socket.io-client"; | ||
|
||
const socket = io("ws://localhost:8080/", {}); | ||
|
||
socket.on("connect", () => { | ||
console.log(`connect ${socket.id}`); | ||
}); | ||
|
||
socket.on("disconnect", () => { | ||
console.log(`disconnect`); | ||
}); | ||
|
||
setInterval(() => { | ||
const start = Date.now(); | ||
socket.emit("ping", () => { | ||
console.log(`pong (latency: ${Date.now() - start} ms)`); | ||
}); | ||
}, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "typescript-example", | ||
"version": "1.0.0", | ||
"description": "An example with TypeScript", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"build": "tsc", | ||
"start:server": "node --no-warnings=ExperimentalWarning --loader ts-node/esm server.ts", | ||
"start:client": "node --no-warnings=ExperimentalWarning --loader ts-node/esm client.ts" | ||
}, | ||
"author": "Damien Arrachequesne", | ||
"license": "MIT", | ||
"dependencies": { | ||
"socket.io": "^4.7.5", | ||
"socket.io-client": "^4.7.5", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Server } from "socket.io"; | ||
|
||
const io = new Server(8080); | ||
|
||
io.on("connection", (socket) => { | ||
console.log(`connect ${socket.id}`); | ||
|
||
socket.on("ping", (cb) => { | ||
console.log("ping"); | ||
cb(); | ||
}); | ||
|
||
socket.on("disconnect", () => { | ||
console.log(`disconnect ${socket.id}`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"target": "es2022", | ||
"module": "esnext", | ||
"moduleResolution": "node" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.