refactor: better socket/entity interface
This commit is contained in:
parent
aa74dc06e4
commit
a7a342cc36
|
@ -31,9 +31,7 @@ function createConnectionListener(avocadoServer) {
|
|||
// Create and track a new entity for the connection.
|
||||
const entity = createEntityForConnection();
|
||||
entityList.addEntity(entity);
|
||||
entity.addTrait('informed');
|
||||
entity.socket = socket;
|
||||
socket.entity = entity;
|
||||
// Listen for events.
|
||||
socket.on('message', createMessageListener(avocadoServer, socket));
|
||||
socket.on('disconnect', createDisconnectionListener(avocadoServer, socket));
|
||||
|
@ -84,6 +82,7 @@ function createEntityForConnection() {
|
|||
},
|
||||
existent: {},
|
||||
graphical: {},
|
||||
informed: {},
|
||||
mobile: {
|
||||
state: {
|
||||
speed: 400,
|
||||
|
|
|
@ -71,6 +71,7 @@ class InformedBase extends Trait {
|
|||
}
|
||||
|
||||
set socket(socket) {
|
||||
socket.entity = this.entity;
|
||||
this._socket = socket;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user