mirror of
https://github.com/esiur/esiur-dart.git
synced 2026-04-03 09:48:21 +00:00
1.3
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
35
lib/src/Net/IIP/DistributedServer.dart
Normal file
35
lib/src/Net/IIP/DistributedServer.dart
Normal 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");
|
||||
|
||||
}
|
||||
12
lib/src/Net/IIP/EntryPoint.dart
Normal file
12
lib/src/Net/IIP/EntryPoint.dart
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user