mirror of
https://github.com/esiur/esiur-dart.git
synced 2025-05-07 20:22:58 +00:00
Fix
This commit is contained in:
parent
f5d3ea9ee5
commit
69f16dae18
@ -145,9 +145,11 @@ class DistributedConnection extends NetworkConnection with IStore {
|
|||||||
|
|
||||||
DateTime? _lastKeepAliveSent;
|
DateTime? _lastKeepAliveSent;
|
||||||
DateTime? _lastKeepAliveReceived;
|
DateTime? _lastKeepAliveReceived;
|
||||||
int jitter;
|
int jitter = 0;
|
||||||
int keepAliveTime = 10;
|
int keepAliveTime = 10;
|
||||||
|
|
||||||
|
DistributedServer? server;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Local username to authenticate ourselves.
|
/// Local username to authenticate ourselves.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -341,9 +343,13 @@ class DistributedConnection extends NetworkConnection with IStore {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (server != null){
|
||||||
// @TODO: check if we need this with reconnect
|
// @TODO: check if we need this with reconnect
|
||||||
// _resources.values.forEach((x) => x.suspend());
|
_resources.values.forEach((x) => x.suspend());
|
||||||
//_unsubscribeAll();
|
_unsubscribeAll();
|
||||||
|
Warehouse.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -743,11 +749,11 @@ class DistributedConnection extends NetworkConnection with IStore {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IIPPacketAction.ProcedureCall:
|
case IIPPacketAction.ProcedureCall:
|
||||||
iipRequestProcedureCall(packet.callbackId, packet.procedure, (TransmissionType)packet.dataType, msg);
|
iipRequestProcedureCall(packet.callbackId, packet.procedure, packet.dataType as TransmissionType, msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IIPPacketAction.StaticCall:
|
case IIPPacketAction.StaticCall:
|
||||||
iipRequestStaticCall(packet.callbackId, packet.classId, packet.methodIndex, (TransmissionType)packet.dataType, msg);
|
iipRequestStaticCall(packet.callbackId, packet.classId, packet.methodIndex, packet.dataType as TransmissionType, msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
@ -851,7 +857,7 @@ class DistributedConnection extends NetworkConnection with IStore {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IIPPacketAction.KeepAlive:
|
case IIPPacketAction.KeepAlive:
|
||||||
iipReply(packet.callbackId, packet.currentTime, packet.jitter);
|
iipReply(packet.callbackId, [packet.currentTime, packet.jitter]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (packet.command == IIPPacketCommand.Report) {
|
} else if (packet.command == IIPPacketCommand.Report) {
|
||||||
@ -1444,7 +1450,7 @@ class DistributedConnection extends NetworkConnection with IStore {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_unsubscrive(r);
|
_unsubscribe(r);
|
||||||
|
|
||||||
var link = DC.stringToBytes(r.instance?.link ?? "");
|
var link = DC.stringToBytes(r.instance?.link ?? "");
|
||||||
|
|
||||||
@ -1527,7 +1533,7 @@ class DistributedConnection extends NetworkConnection with IStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _unsubscribeAll(){
|
void _unsubscribeAll(){
|
||||||
_subscriptions.forEach((resource, value) => {
|
_subscriptions.forEach((resource, value) {
|
||||||
resource.instance?.off("resourceEventOccurred", _instance_EventOccurred);
|
resource.instance?.off("resourceEventOccurred", _instance_EventOccurred);
|
||||||
resource.instance?.off("resourceModified", _instance_PropertyModified);
|
resource.instance?.off("resourceModified", _instance_PropertyModified);
|
||||||
resource.instance?.off("resourceDestroyed", _instance_ResourceDestroyed);
|
resource.instance?.off("resourceDestroyed", _instance_ResourceDestroyed);
|
||||||
@ -2110,7 +2116,7 @@ void _unsubscribeAll(){
|
|||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestStaticCall(int callback, Guid classId, int index, TransmissionType transmissionType, DC content)
|
void iipRequestStaticCall(int callback, Guid classId, int index, TransmissionType transmissionType, DC content)
|
||||||
{
|
{
|
||||||
var template = Warehouse.getTemplateByClassId(classId);
|
var template = Warehouse.getTemplateByClassId(classId);
|
||||||
|
|
||||||
@ -2973,7 +2979,7 @@ void _unsubscribeAll(){
|
|||||||
|
|
||||||
_instance_ResourceDestroyed(IResource resource) {
|
_instance_ResourceDestroyed(IResource resource) {
|
||||||
// compose the packet
|
// compose the packet
|
||||||
_unsubscrive(resource);
|
_unsubscribe(resource);
|
||||||
sendEvent(IIPPacketEvent.ResourceDestroyed)
|
sendEvent(IIPPacketEvent.ResourceDestroyed)
|
||||||
..addUint32((resource.instance as Instance).id)
|
..addUint32((resource.instance as Instance).id)
|
||||||
..done();
|
..done();
|
||||||
|
@ -24,6 +24,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import '../../Data/IntType.dart';
|
import '../../Data/IntType.dart';
|
||||||
|
|
||||||
@ -244,15 +245,17 @@ class DistributedResource extends IResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AsyncReply<dynamic> internal_invoke(int index, Map<UInt8, dynamic> args) {
|
AsyncReply<dynamic> internal_invoke(int index, Map<UInt8, dynamic> args) {
|
||||||
if (_destroyed) throw new Exception("Trying to access destroyed object");
|
if (_destroyed) throw new Exception("Trying to access a destroyed object");
|
||||||
|
|
||||||
if (_suspended) throw new Exception("Trying to access suspended object");
|
if (_suspended) throw new Exception("Trying to access a suspended object.");
|
||||||
if (instance == null) throw Exception("Object not initialized.");
|
if (instance == null) throw Exception("Object not initialized.");
|
||||||
|
|
||||||
|
if (_connection == null) throw new Exception("No connection.");
|
||||||
|
|
||||||
var ins = instance as Instance;
|
var ins = instance as Instance;
|
||||||
|
|
||||||
if (index >= ins.template.functions.length)
|
if (index >= ins.template.functions.length)
|
||||||
throw new Exception("Function index is incorrect");
|
throw new Exception("Function index is incorrect.");
|
||||||
|
|
||||||
// return _connection?.sendInvoke(_instanceId as int, index, args)
|
// return _connection?.sendInvoke(_instanceId as int, index, args)
|
||||||
// as AsyncReply;
|
// as AsyncReply;
|
||||||
@ -262,9 +265,9 @@ class DistributedResource extends IResource {
|
|||||||
if (ft == null) throw new Exception("Function template not found.");
|
if (ft == null) throw new Exception("Function template not found.");
|
||||||
|
|
||||||
if (ft.isStatic)
|
if (ft.isStatic)
|
||||||
return _connection?.staticCall(ins.template.classId, index, args);
|
return _connection!.staticCall(ins.template.classId, index, args);
|
||||||
else
|
else
|
||||||
return _connection?.sendInvoke(_instanceId as Int, index, args);
|
return _connection!.sendInvoke(_instanceId as int, index, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator [](String index) {
|
operator [](String index) {
|
||||||
|
@ -86,9 +86,9 @@ class Func {
|
|||||||
final List<Arg> argsType;
|
final List<Arg> argsType;
|
||||||
//final bool isNullable;
|
//final bool isNullable;
|
||||||
final String? annotation;
|
final String? annotation;
|
||||||
|
final bool isStatic;
|
||||||
const Func(this.name, this.returnType, this.argsType,
|
const Func(this.name, this.returnType, this.argsType,
|
||||||
[this.annotation = null]);
|
[this.annotation = null, this.isStatic = false]);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Arg {
|
class Arg {
|
||||||
|
@ -221,6 +221,7 @@ class TypeTemplate {
|
|||||||
i,
|
i,
|
||||||
fi.name,
|
fi.name,
|
||||||
false,
|
false,
|
||||||
|
fi.isStatic,
|
||||||
args,
|
args,
|
||||||
RepresentationType.fromType(fi.returnType) ??
|
RepresentationType.fromType(fi.returnType) ??
|
||||||
RepresentationType.Void,
|
RepresentationType.Void,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user