Commit 66d3c2b1 authored by 潘栩锋's avatar 潘栩锋 🚴

修复 Reflect_SeviceClient 当property 太多, 第1次获取全部 property, 这个大包接收的时间比较长, 中途…

修复 Reflect_SeviceClient 当property 太多, 第1次获取全部 property,  这个大包接收的时间比较长, 中途 propertychanged 产生, 会被最后的 大包覆盖。。。 所以需要对中途的 propertychanged缓存
parent 7d29227d
...@@ -46,6 +46,17 @@ namespace FObjBase.Reflect ...@@ -46,6 +46,17 @@ namespace FObjBase.Reflect
SubPropertyNode rootNode; SubPropertyNode rootNode;
List<string> properties = new List<string>(); List<string> properties = new List<string>();
/// <summary>
/// 缓存 发出 CALL_GetAllProperties指令,到收到回复 之间时段的 全部推送
/// </summary>
List<PushInfoData> pushInfoList = new List<PushInfoData>();
class PushInfoData
{
public bool isPushPropertyChanged;
public Reflect_OBJ_INTERFACE.ReflectData rData;
}
#endregion #endregion
public Reflect_SeviceClient(UInt32 id) : base(id) { public Reflect_SeviceClient(UInt32 id) : base(id) {
...@@ -79,6 +90,7 @@ namespace FObjBase.Reflect ...@@ -79,6 +90,7 @@ namespace FObjBase.Reflect
if (IsConnected == false) if (IsConnected == false)
{ {
IsSynced = false; IsSynced = false;
pushInfoList.Clear();
} }
} }
}; };
...@@ -249,8 +261,9 @@ namespace FObjBase.Reflect ...@@ -249,8 +261,9 @@ namespace FObjBase.Reflect
void request_CALL_GetAllProperties(Reflect_OBJ_INTERFACE.ReflectData rData) void request_CALL_GetAllProperties(Reflect_OBJ_INTERFACE.ReflectData rData)
{ {
IsSynced = true;
request_PUSH_PropertyChanged(rData); request_PUSH_PropertyChanged(rData);
IsSynced = true;
DealPushInfoList();
} }
void request_PUSH_PropertyChanged(Reflect_OBJ_INTERFACE.ReflectData rData) void request_PUSH_PropertyChanged(Reflect_OBJ_INTERFACE.ReflectData rData)
{ {
...@@ -343,30 +356,57 @@ namespace FObjBase.Reflect ...@@ -343,30 +356,57 @@ namespace FObjBase.Reflect
} }
} }
public override void PushInfo(IFConn from, uint srcid, ushort infoid, byte[] infodata) public override void PushInfo(IFConn from, uint srcid, ushort infoid, byte[] infodata)
{ {
switch (infoid) switch (infoid)
{ {
case Reflect_OBJ_INTERFACE.PUSH_PropertyChanged: case Reflect_OBJ_INTERFACE.PUSH_PropertyChanged:
case Reflect_OBJ_INTERFACE.PUSH_Event:
{ {
string json = Misc.Converter.BytesToString(infodata); string json = Misc.Converter.BytesToString(infodata);
var rData = JsonConvert.DeserializeObject<Reflect_OBJ_INTERFACE.ReflectData>(json); var rData = JsonConvert.DeserializeObject<Reflect_OBJ_INTERFACE.ReflectData>(json);
request_PUSH_PropertyChanged(rData); if (!IsSynced)
}
break;
case Reflect_OBJ_INTERFACE.PUSH_Event:
{ {
string json = Misc.Converter.BytesToString(infodata); //还没同步完成,先缓存
var rData = JsonConvert.DeserializeObject<Reflect_OBJ_INTERFACE.ReflectData>(json); pushInfoList.Add(
new PushInfoData() {
isPushPropertyChanged = (infoid == Reflect_OBJ_INTERFACE.PUSH_PropertyChanged),
rData = rData });
return;
}
if(infoid == Reflect_OBJ_INTERFACE.PUSH_PropertyChanged)
request_PUSH_PropertyChanged(rData);
else
request_PUSH_Event(rData); request_PUSH_Event(rData);
} }
break; break;
} }
} }
/// <summary>
/// 处理全部 缓存的推送数据
/// </summary>
void DealPushInfoList()
{
for (int i = 0; i < pushInfoList.Count(); i++)
{
var pushInfoData = pushInfoList[i];
if(pushInfoData.isPushPropertyChanged)
request_PUSH_PropertyChanged(pushInfoData.rData);
else
request_PUSH_Event(pushInfoData.rData);
}
pushInfoList.Clear();
}
public override void PushCallFunction(IFConn from, uint srcid, uint magic, ushort funcid, byte[] retdata, object asyncDelegate, object asyncContext) public override void PushCallFunction(IFConn from, uint srcid, uint magic, ushort funcid, byte[] retdata, object asyncDelegate, object asyncContext)
{ {
switch (funcid) switch (funcid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment