mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 07:04:53 +09:00
Refactor message registration and validation
Split up the action of registring an event or request data class to be decoded by the Link class and the action of registring a handler for those requests and events. This moves the validation work from Link instantiation time to startup initialisation which makes logic errors fail on startup instead of failing instantiation of the link when a connection attempt is made. Additionally implement a partial validation logic for messages received using the newly refactored message registration. This unfortunately ended up merged with the registration refactor.
This commit is contained in:
1 parent
bcd94709d2
commit
7f8a700716
39 files changed
+648
-332
No files matched your search
@@ -19,13 +19,13 @@ class BaseConnection extends libLink.Link {
|
||||
super(connector);
|
||||
this.router = new ControllerRouter(controller);
|
||||
this._controller = controller;
|
||||
for (let [Request, handler] of controller._registeredRequests) { this.register(Request, handler); }
|
||||
for (let [Request, handler] of controller._registeredRequests) { this.handle(Request, handler); }
|
||||
for (let [Request, handler] of controller._fallbackedRequests) { this.fallbackRequest(Request, handler); }
|
||||
for (let [Event, handler] of controller._registeredEvents) { this.register(Event, handler); }
|
||||
for (let [Event, handler] of controller._registeredEvents) { this.handle(Event, handler); }
|
||||
for (let [Event, handler] of controller._snoopedEvents) { this.snoopEvent(Event, handler); }
|
||||
|
||||
this.register(libData.ModPackGetRequest, this.handleModPackGetRequest.bind(this));
|
||||
this.register(libData.ModPackGetDefaultRequest, this.handleModPackGetDefaultRequest.bind(this));
|
||||
this.handle(libData.ModPackGetRequest, this.handleModPackGetRequest.bind(this));
|
||||
this.handle(libData.ModPackGetDefaultRequest, this.handleModPackGetDefaultRequest.bind(this));
|
||||
}
|
||||
|
||||
async disconnect(code, reason) {
|
||||
|
||||
Reference in new issue
Block a user