refactor: synchronizer
This commit is contained in:
parent
61cfc053e5
commit
f54b6fc1d6
|
@ -98,7 +98,7 @@
|
|||
'@flecks/web/client':
|
||||
up:
|
||||
- '@flecks/socket'
|
||||
- '@humus/universe'
|
||||
- '@humus/app'
|
||||
- '@flecks/react'
|
||||
- '...'
|
||||
'@flecks/web/server':
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
"files": [
|
||||
"assets",
|
||||
"build",
|
||||
"client.js",
|
||||
"client.js.map",
|
||||
"index.css",
|
||||
"index.css.map",
|
||||
"index.js",
|
||||
|
@ -31,6 +33,8 @@
|
|||
"@avocado/input": "^3.0.0",
|
||||
"@avocado/math": "^3.0.0",
|
||||
"@avocado/react": "^3.0.0",
|
||||
"@avocado/resource": "^3.0.0",
|
||||
"@avocado/s13n": "^3.0.0",
|
||||
"@avocado/topdown": "^3.0.0",
|
||||
"@flecks/core": "^1.4.1",
|
||||
"@flecks/react": "^1.4.1",
|
||||
|
|
|
@ -8,8 +8,8 @@ export default {
|
|||
window.flecks = flecks;
|
||||
const Synchronizer = Receiver(flecks);
|
||||
const synchronizer = new Synchronizer();
|
||||
flecks.set('$humus/universe.synchronizer', synchronizer);
|
||||
flecks.get('$flecks/socket.socket').on('packet', synchronizer.acceptPacket, synchronizer);
|
||||
flecks.set('$humus/app.synchronizer', synchronizer);
|
||||
synchronizer.listenTo(flecks.get('$flecks/socket.socket'));
|
||||
},
|
||||
},
|
||||
};
|
|
@ -19,5 +19,9 @@ export default (flecks) => {
|
|||
}
|
||||
}
|
||||
|
||||
listenTo(socket) {
|
||||
socket.on('packet', this.acceptPacket, this);
|
||||
}
|
||||
|
||||
};
|
||||
};
|
|
@ -9,7 +9,7 @@ export default () => {
|
|||
const flecks = useFlecks();
|
||||
const [room, setRoom] = useState(flecks.get('$humus/app.room'));
|
||||
const socket = useSocket();
|
||||
const synchronizer = flecks.get('$humus/universe.synchronizer');
|
||||
const synchronizer = flecks.get('$humus/app.synchronizer');
|
||||
useEffect(() => {
|
||||
if (!room) {
|
||||
return undefined;
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
"files": [
|
||||
"assets",
|
||||
"build",
|
||||
"client.js",
|
||||
"client.js.map",
|
||||
"index.css",
|
||||
"index.css.map",
|
||||
"index.js",
|
||||
|
@ -34,7 +32,6 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"@avocado/resource": "^3.0.0",
|
||||
"@avocado/s13n": "^3.0.0",
|
||||
"@avocado/timing": "^3.0.0",
|
||||
"@avocado/traits": "^3.0.0",
|
||||
"@flecks/core": "^1.4.1",
|
||||
|
|
Loading…
Reference in New Issue
Block a user