mirror of
https://github.com/artegoser/AnoPaper.git
synced 2025-02-23 12:43:14 +03:00
feat: socket.io support
This commit is contained in:
parent
697439f7b4
commit
68aa1527cb
4 changed files with 389 additions and 4 deletions
19
src/App.jsx
19
src/App.jsx
|
@ -10,6 +10,7 @@ import PubNote from "./pages/pubNote";
|
|||
import PubError from "./pages/pubError";
|
||||
import PubNoteSafe from "./pages/pubNoteSafe";
|
||||
import RenderMarkdown from "./components/markdown";
|
||||
import { io } from "socket.io-client";
|
||||
|
||||
function App() {
|
||||
Storage.prototype.setObj = function (key, obj) {
|
||||
|
@ -19,6 +20,24 @@ function App() {
|
|||
return JSON.parse(this.getItem(key)) || {};
|
||||
};
|
||||
|
||||
const socket = io();
|
||||
|
||||
function onConnect() {
|
||||
console.log("connect");
|
||||
}
|
||||
|
||||
function onDisconnect() {
|
||||
console.log("disconnect");
|
||||
}
|
||||
|
||||
function onFooEvent(value) {
|
||||
console.log("foo event", value);
|
||||
}
|
||||
|
||||
socket.on("connect", onConnect);
|
||||
socket.on("disconnect", onDisconnect);
|
||||
socket.on("foo", onFooEvent);
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-4 lg:grid-cols-5 gap-10 text-black dark:text-white">
|
||||
<Menu />
|
||||
|
|
Loading…
Add table
Reference in a new issue