refactor: synchronizer

This commit is contained in:
cha0s 2022-05-01 09:57:06 -05:00
parent 61cfc053e5
commit f54b6fc1d6
6 changed files with 12 additions and 7 deletions

View File

@ -98,7 +98,7 @@
'@flecks/web/client': '@flecks/web/client':
up: up:
- '@flecks/socket' - '@flecks/socket'
- '@humus/universe' - '@humus/app'
- '@flecks/react' - '@flecks/react'
- '...' - '...'
'@flecks/web/server': '@flecks/web/server':

View File

@ -17,6 +17,8 @@
"files": [ "files": [
"assets", "assets",
"build", "build",
"client.js",
"client.js.map",
"index.css", "index.css",
"index.css.map", "index.css.map",
"index.js", "index.js",
@ -31,6 +33,8 @@
"@avocado/input": "^3.0.0", "@avocado/input": "^3.0.0",
"@avocado/math": "^3.0.0", "@avocado/math": "^3.0.0",
"@avocado/react": "^3.0.0", "@avocado/react": "^3.0.0",
"@avocado/resource": "^3.0.0",
"@avocado/s13n": "^3.0.0",
"@avocado/topdown": "^3.0.0", "@avocado/topdown": "^3.0.0",
"@flecks/core": "^1.4.1", "@flecks/core": "^1.4.1",
"@flecks/react": "^1.4.1", "@flecks/react": "^1.4.1",

View File

@ -8,8 +8,8 @@ export default {
window.flecks = flecks; window.flecks = flecks;
const Synchronizer = Receiver(flecks); const Synchronizer = Receiver(flecks);
const synchronizer = new Synchronizer(); const synchronizer = new Synchronizer();
flecks.set('$humus/universe.synchronizer', synchronizer); flecks.set('$humus/app.synchronizer', synchronizer);
flecks.get('$flecks/socket.socket').on('packet', synchronizer.acceptPacket, synchronizer); synchronizer.listenTo(flecks.get('$flecks/socket.socket'));
}, },
}, },
}; };

View File

@ -19,5 +19,9 @@ export default (flecks) => {
} }
} }
listenTo(socket) {
socket.on('packet', this.acceptPacket, this);
}
}; };
}; };

View File

@ -9,7 +9,7 @@ export default () => {
const flecks = useFlecks(); const flecks = useFlecks();
const [room, setRoom] = useState(flecks.get('$humus/app.room')); const [room, setRoom] = useState(flecks.get('$humus/app.room'));
const socket = useSocket(); const socket = useSocket();
const synchronizer = flecks.get('$humus/universe.synchronizer'); const synchronizer = flecks.get('$humus/app.synchronizer');
useEffect(() => { useEffect(() => {
if (!room) { if (!room) {
return undefined; return undefined;

View File

@ -19,8 +19,6 @@
"files": [ "files": [
"assets", "assets",
"build", "build",
"client.js",
"client.js.map",
"index.css", "index.css",
"index.css.map", "index.css.map",
"index.js", "index.js",
@ -34,7 +32,6 @@
], ],
"dependencies": { "dependencies": {
"@avocado/resource": "^3.0.0", "@avocado/resource": "^3.0.0",
"@avocado/s13n": "^3.0.0",
"@avocado/timing": "^3.0.0", "@avocado/timing": "^3.0.0",
"@avocado/traits": "^3.0.0", "@avocado/traits": "^3.0.0",
"@flecks/core": "^1.4.1", "@flecks/core": "^1.4.1",