mirror of
https://github.com/esiur/esiur-dart.git
synced 2025-05-06 04:02:57 +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? _lastKeepAliveReceived;
|
||||
int jitter;
|
||||
int jitter = 0;
|
||||
int keepAliveTime = 10;
|
||||
|
||||
DistributedServer? server;
|
||||
|
||||
/// <summary>
|
||||
/// Local username to authenticate ourselves.
|
||||
/// </summary>
|
||||
@ -341,9 +343,13 @@ class DistributedConnection extends NetworkConnection with IStore {
|
||||
|
||||
|
||||
|
||||
if (server != null){
|
||||
// @TODO: check if we need this with reconnect
|
||||
// _resources.values.forEach((x) => x.suspend());
|
||||
//_unsubscribeAll();
|
||||
_resources.values.forEach((x) => x.suspend());
|
||||
_unsubscribeAll();
|
||||
Warehouse.remove(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -743,11 +749,11 @@ class DistributedConnection extends NetworkConnection with IStore {
|
||||
break;
|
||||
|
||||
case IIPPacketAction.ProcedureCall:
|
||||
iipRequestProcedureCall(packet.callbackId, packet.procedure, (TransmissionType)packet.dataType, msg);
|
||||
iipRequestProcedureCall(packet.callbackId, packet.procedure, packet.dataType as TransmissionType, msg);
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@ -851,7 +857,7 @@ class DistributedConnection extends NetworkConnection with IStore {
|
||||
break;
|
||||
|
||||
case IIPPacketAction.KeepAlive:
|
||||
iipReply(packet.callbackId, packet.currentTime, packet.jitter);
|
||||
iipReply(packet.callbackId, [packet.currentTime, packet.jitter]);
|
||||
break;
|
||||
}
|
||||
} else if (packet.command == IIPPacketCommand.Report) {
|
||||
@ -1444,7 +1450,7 @@ class DistributedConnection extends NetworkConnection with IStore {
|
||||
return;
|
||||
}
|
||||
|
||||
_unsubscrive(r);
|
||||
_unsubscribe(r);
|
||||
|
||||
var link = DC.stringToBytes(r.instance?.link ?? "");
|
||||
|
||||
@ -1527,7 +1533,7 @@ class DistributedConnection extends NetworkConnection with IStore {
|
||||
}
|
||||
|
||||
void _unsubscribeAll(){
|
||||
_subscriptions.forEach((resource, value) => {
|
||||
_subscriptions.forEach((resource, value) {
|
||||
resource.instance?.off("resourceEventOccurred", _instance_EventOccurred);
|
||||
resource.instance?.off("resourceModified", _instance_PropertyModified);
|
||||
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);
|
||||
|
||||
@ -2973,7 +2979,7 @@ void _unsubscribeAll(){
|
||||
|
||||
_instance_ResourceDestroyed(IResource resource) {
|
||||
// compose the packet
|
||||
_unsubscrive(resource);
|
||||
_unsubscribe(resource);
|
||||
sendEvent(IIPPacketEvent.ResourceDestroyed)
|
||||
..addUint32((resource.instance as Instance).id)
|
||||
..done();
|
||||
|
@ -24,6 +24,7 @@ SOFTWARE.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import '../../Data/IntType.dart';
|
||||
|
||||
@ -244,15 +245,17 @@ class DistributedResource extends IResource {
|
||||
}
|
||||
|
||||
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 (_connection == null) throw new Exception("No connection.");
|
||||
|
||||
var ins = instance as Instance;
|
||||
|
||||
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)
|
||||
// as AsyncReply;
|
||||
@ -262,9 +265,9 @@ class DistributedResource extends IResource {
|
||||
if (ft == null) throw new Exception("Function template not found.");
|
||||
|
||||
if (ft.isStatic)
|
||||
return _connection?.staticCall(ins.template.classId, index, args);
|
||||
return _connection!.staticCall(ins.template.classId, index, args);
|
||||
else
|
||||
return _connection?.sendInvoke(_instanceId as Int, index, args);
|
||||
return _connection!.sendInvoke(_instanceId as int, index, args);
|
||||
}
|
||||
|
||||
operator [](String index) {
|
||||
|
@ -86,9 +86,9 @@ class Func {
|
||||
final List<Arg> argsType;
|
||||
//final bool isNullable;
|
||||
final String? annotation;
|
||||
|
||||
final bool isStatic;
|
||||
const Func(this.name, this.returnType, this.argsType,
|
||||
[this.annotation = null]);
|
||||
[this.annotation = null, this.isStatic = false]);
|
||||
}
|
||||
|
||||
class Arg {
|
||||
|
@ -221,6 +221,7 @@ class TypeTemplate {
|
||||
i,
|
||||
fi.name,
|
||||
false,
|
||||
fi.isStatic,
|
||||
args,
|
||||
RepresentationType.fromType(fi.returnType) ??
|
||||
RepresentationType.Void,
|
||||
|
Loading…
x
Reference in New Issue
Block a user