Skip to content

Commit d4f2d81

Browse files
committed
up
1 parent 3c6a24f commit d4f2d81

File tree

13 files changed

+1174
-344
lines changed

13 files changed

+1174
-344
lines changed

Assets/Plugins/kbengine/kbengine_unity3d_plugins/AccountBase.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,21 @@ public override void onRemoteMethodCall(MemoryStream stream)
7070
UInt16 methodUtype = 0;
7171
UInt16 componentPropertyUType = 0;
7272

73-
if(sm.useMethodDescrAlias)
73+
if(sm.usePropertyDescrAlias)
7474
{
7575
componentPropertyUType = stream.readUint8();
76-
methodUtype = stream.readUint8();
7776
}
7877
else
7978
{
8079
componentPropertyUType = stream.readUint16();
80+
}
81+
82+
if(sm.useMethodDescrAlias)
83+
{
84+
methodUtype = stream.readUint8();
85+
}
86+
else
87+
{
8188
methodUtype = stream.readUint16();
8289
}
8390

Assets/Plugins/kbengine/kbengine_unity3d_plugins/AvatarBase.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,21 @@ public override void onRemoteMethodCall(MemoryStream stream)
155155
UInt16 methodUtype = 0;
156156
UInt16 componentPropertyUType = 0;
157157

158-
if(sm.useMethodDescrAlias)
158+
if(sm.usePropertyDescrAlias)
159159
{
160160
componentPropertyUType = stream.readUint8();
161-
methodUtype = stream.readUint8();
162161
}
163162
else
164163
{
165164
componentPropertyUType = stream.readUint16();
165+
}
166+
167+
if(sm.useMethodDescrAlias)
168+
{
169+
methodUtype = stream.readUint8();
170+
}
171+
else
172+
{
166173
methodUtype = stream.readUint16();
167174
}
168175

Assets/Plugins/kbengine/kbengine_unity3d_plugins/Bundle.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,20 @@ public Bundle()
2525

2626
public void clear()
2727
{
28-
stream = MemoryStream.createObject();
29-
streamList = new List<MemoryStream>();
28+
// 把不用的MemoryStream放回缓冲池,以减少垃圾回收的消耗
29+
for (int i = 0; i < streamList.Count; ++i)
30+
{
31+
if (stream != streamList[i])
32+
streamList[i].reclaimObject();
33+
}
34+
35+
streamList.Clear();
36+
37+
if(stream != null)
38+
stream.clear();
39+
else
40+
stream = MemoryStream.createObject();
41+
3042
numMessage = 0;
3143
messageLength = 0;
3244
msgtype = null;
@@ -110,21 +122,12 @@ public void send(NetworkInterfaceBase networkInterface)
110122
Dbg.ERROR_MSG("Bundle::send: networkInterface invalid!");
111123
}
112124

113-
// 把不用的MemoryStream放回缓冲池,以减少垃圾回收的消耗
114-
for (int i = 0; i < streamList.Count; ++i)
115-
{
116-
streamList[i].reclaimObject();
117-
}
118-
119-
streamList.Clear();
120-
stream.clear();
121-
122125
// 我们认为,发送完成,就视为这个bundle不再使用了,
123126
// 所以我们会把它放回对象池,以减少垃圾回收带来的消耗,
124127
// 如果需要继续使用,应该重新Bundle.createObject(),
125128
// 如果外面不重新createObject()而直接使用,就可能会出现莫名的问题,
126129
// 仅以此备注,警示使用者。
127-
Bundle.reclaimObject(this);
130+
reclaimObject();
128131
}
129132

130133
public void checkStream(int v)

Assets/Plugins/kbengine/kbengine_unity3d_plugins/GateBase.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,21 @@ public override void onRemoteMethodCall(MemoryStream stream)
7777
UInt16 methodUtype = 0;
7878
UInt16 componentPropertyUType = 0;
7979

80-
if(sm.useMethodDescrAlias)
80+
if(sm.usePropertyDescrAlias)
8181
{
8282
componentPropertyUType = stream.readUint8();
83-
methodUtype = stream.readUint8();
8483
}
8584
else
8685
{
8786
componentPropertyUType = stream.readUint16();
87+
}
88+
89+
if(sm.useMethodDescrAlias)
90+
{
91+
methodUtype = stream.readUint8();
92+
}
93+
else
94+
{
8895
methodUtype = stream.readUint16();
8996
}
9097

Assets/Plugins/kbengine/kbengine_unity3d_plugins/KBEMain.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class KBEMain : MonoBehaviour
3131
public bool isOnInitCallPropertysSetMethods = true;
3232
public bool forceDisableUDP = false;
3333

34+
public bool automaticallyUpdateSDK = true;
35+
3436
protected virtual void Awake()
3537
{
3638
DontDestroyOnLoad(transform.gameObject);
@@ -46,8 +48,26 @@ protected virtual void Start ()
4648

4749
public virtual void installEvents()
4850
{
51+
KBEngine.Event.registerOut(EventOutTypes.onVersionNotMatch, this, "onVersionNotMatch");
52+
KBEngine.Event.registerOut(EventOutTypes.onScriptVersionNotMatch, this, "onScriptVersionNotMatch");
4953
}
5054

55+
public void onVersionNotMatch(string verInfo, string serVerInfo)
56+
{
57+
#if UNITY_EDITOR
58+
if(automaticallyUpdateSDK)
59+
gameObject.AddComponent<ClientSDKUpdater>();
60+
#endif
61+
}
62+
63+
public void onScriptVersionNotMatch(string verInfo, string serVerInfo)
64+
{
65+
#if UNITY_EDITOR
66+
if(automaticallyUpdateSDK)
67+
gameObject.AddComponent<ClientSDKUpdater>();
68+
#endif
69+
}
70+
5171
public virtual void initKBEngine()
5272
{
5373
// 如果此处发生错误,请查看 Assets\Scripts\kbe_scripts\if_Entity_error_use______git_submodule_update_____kbengine_plugins_______open_this_file_and_I_will_tell_you.cs
@@ -88,6 +108,7 @@ protected virtual void OnDestroy()
88108
KBEngineApp.app.destroy();
89109
KBEngineApp.app = null;
90110
}
111+
KBEngine.Event.clear();
91112
MonoBehaviour.print("clientapp::OnDestroy(): end");
92113
}
93114

0 commit comments

Comments
 (0)