2
0
mirror of https://github.com/esiur/esiur-dart.git synced 2026-04-03 09:48:21 +00:00
This commit is contained in:
2021-07-14 05:16:40 +03:00
parent 7971c836b7
commit 737397da11
50 changed files with 6238 additions and 4926 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -41,11 +41,12 @@ class DistributedResource extends IResource {
//bool _isReady = false;
String _link;
int _age;
List _properties;
bool _destroyed = false;
List<KeyValuePair<int, dynamic>> _queued_updates =
List<KeyValuePair<int, dynamic>>();
List<KeyValuePair<int, dynamic>> _queued_updates = [];
/// <summary>
/// Connection responsible for the distributed resource.
@@ -111,6 +112,15 @@ class DistributedResource extends IResource {
this._link = link;
this._connection = connection;
this._instanceId = instanceId;
this._age = age;
}
void init(
DistributedConnection connection, int instanceId, int age, String link) {
this._link = link;
this._connection = connection;
this._instanceId = instanceId;
this._age = age;
}
//void _ready()
@@ -165,6 +175,38 @@ class DistributedResource extends IResource {
return true;
}
AsyncReply<dynamic> listen(event) {
EventTemplate et = event is EventTemplate
? event
: instance.template.getEventTemplateByName(event);
if (et == null)
return AsyncReply<dynamic>().triggerError(new AsyncException(
ErrorType.Management, ExceptionCode.MethodNotFound.index, ""));
if (!et.listenable)
return AsyncReply().triggerError(new AsyncException(
ErrorType.Management, ExceptionCode.NotListenable.index, ""));
return _connection.sendListenRequest(_instanceId, et.index);
}
AsyncReply<dynamic> unlisten(event) {
EventTemplate et = event is EventTemplate
? event
: instance.template.getEventTemplateByName(event);
if (et == null)
return AsyncReply().triggerError(new AsyncException(
ErrorType.Management, ExceptionCode.MethodNotFound.index, ""));
if (!et.listenable)
return AsyncReply().triggerError(new AsyncException(
ErrorType.Management, ExceptionCode.NotListenable.index, ""));
return connection.sendUnlistenRequest(_instanceId, et.index);
}
void emitEventByIndex(int index, dynamic args) {
// neglect events when the object is not yet attached
if (!_attached) return;

View File

@@ -0,0 +1,35 @@
import 'package:esiur/src/Resource/Template/TemplateDescriber.dart';
import '../../Resource/IResource.dart';
import '../../Core/AsyncReply.dart';
import '../../Resource/ResourceTrigger.dart';
import './EntryPoint.dart';
class DistributedServer extends IResource {
@override
void destroy() {
this.emitArgs("destroy", []);
}
@override
AsyncReply<bool> trigger(ResourceTrigger trigger) {
return AsyncReply.ready(true);
}
EntryPoint entryPoint;
@override
getProperty(String name) => null;
@override
invoke(String name, List arguments) => null;
@override
setProperty(String name, value) => true;
@override
TemplateDescriber get template =>
TemplateDescriber("Esiur.Net.IIP.DistributedServer");
}

View File

@@ -0,0 +1,12 @@
import '../../Resource/IResource.dart';
import './DistributedConnection.dart';
import '../../Core/AsyncReply.dart';
abstract class EntryPoint extends IResource
{
AsyncReply<List<IResource>> query(String path, DistributedConnection sender);
bool create();
}