addService<Id, Data> method
Keeps service, which close closes, as a Service of Id and
Data.
Throws an ArgumentError if Data is not nullable: the methods of a
WebSocketsService return null, as their results come as events.
Implementation
@protected
Service<Id, Data> addService<Id, Data>(WebSocketsService service) {
if (service is! Service<Id, Data>) {
throw ArgumentError(
'The data of a WebSocket service is given as events, and its methods '
'return null, so its type must be nullable: use '
'service<$Id, $Data?>(...), not service<$Id, $Data>(...).',
);
}
_services.add(service);
return service as Service<Id, Data>;
}