Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
kebiao committed Feb 15, 2019
1 parent 3c6a24f commit d4f2d81
Show file tree
Hide file tree
Showing 13 changed files with 1,174 additions and 344 deletions.
11 changes: 9 additions & 2 deletions Assets/Plugins/kbengine/kbengine_unity3d_plugins/AccountBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,21 @@ public override void onRemoteMethodCall(MemoryStream stream)
UInt16 methodUtype = 0;
UInt16 componentPropertyUType = 0;

if(sm.useMethodDescrAlias)
if(sm.usePropertyDescrAlias)
{
componentPropertyUType = stream.readUint8();
methodUtype = stream.readUint8();
}
else
{
componentPropertyUType = stream.readUint16();
}

if(sm.useMethodDescrAlias)
{
methodUtype = stream.readUint8();
}
else
{
methodUtype = stream.readUint16();
}

Expand Down
11 changes: 9 additions & 2 deletions Assets/Plugins/kbengine/kbengine_unity3d_plugins/AvatarBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,21 @@ public override void onRemoteMethodCall(MemoryStream stream)
UInt16 methodUtype = 0;
UInt16 componentPropertyUType = 0;

if(sm.useMethodDescrAlias)
if(sm.usePropertyDescrAlias)
{
componentPropertyUType = stream.readUint8();
methodUtype = stream.readUint8();
}
else
{
componentPropertyUType = stream.readUint16();
}

if(sm.useMethodDescrAlias)
{
methodUtype = stream.readUint8();
}
else
{
methodUtype = stream.readUint16();
}

Expand Down
27 changes: 15 additions & 12 deletions Assets/Plugins/kbengine/kbengine_unity3d_plugins/Bundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ public Bundle()

public void clear()
{
stream = MemoryStream.createObject();
streamList = new List<MemoryStream>();
// 把不用的MemoryStream放回缓冲池,以减少垃圾回收的消耗
for (int i = 0; i < streamList.Count; ++i)
{
if (stream != streamList[i])
streamList[i].reclaimObject();
}

streamList.Clear();

if(stream != null)
stream.clear();
else
stream = MemoryStream.createObject();

numMessage = 0;
messageLength = 0;
msgtype = null;
Expand Down Expand Up @@ -110,21 +122,12 @@ public void send(NetworkInterfaceBase networkInterface)
Dbg.ERROR_MSG("Bundle::send: networkInterface invalid!");
}

// 把不用的MemoryStream放回缓冲池,以减少垃圾回收的消耗
for (int i = 0; i < streamList.Count; ++i)
{
streamList[i].reclaimObject();
}

streamList.Clear();
stream.clear();

// 我们认为,发送完成,就视为这个bundle不再使用了,
// 所以我们会把它放回对象池,以减少垃圾回收带来的消耗,
// 如果需要继续使用,应该重新Bundle.createObject(),
// 如果外面不重新createObject()而直接使用,就可能会出现莫名的问题,
// 仅以此备注,警示使用者。
Bundle.reclaimObject(this);
reclaimObject();
}

public void checkStream(int v)
Expand Down
11 changes: 9 additions & 2 deletions Assets/Plugins/kbengine/kbengine_unity3d_plugins/GateBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,21 @@ public override void onRemoteMethodCall(MemoryStream stream)
UInt16 methodUtype = 0;
UInt16 componentPropertyUType = 0;

if(sm.useMethodDescrAlias)
if(sm.usePropertyDescrAlias)
{
componentPropertyUType = stream.readUint8();
methodUtype = stream.readUint8();
}
else
{
componentPropertyUType = stream.readUint16();
}

if(sm.useMethodDescrAlias)
{
methodUtype = stream.readUint8();
}
else
{
methodUtype = stream.readUint16();
}

Expand Down
21 changes: 21 additions & 0 deletions Assets/Plugins/kbengine/kbengine_unity3d_plugins/KBEMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class KBEMain : MonoBehaviour
public bool isOnInitCallPropertysSetMethods = true;
public bool forceDisableUDP = false;

public bool automaticallyUpdateSDK = true;

protected virtual void Awake()
{
DontDestroyOnLoad(transform.gameObject);
Expand All @@ -46,8 +48,26 @@ protected virtual void Start ()

public virtual void installEvents()
{
KBEngine.Event.registerOut(EventOutTypes.onVersionNotMatch, this, "onVersionNotMatch");
KBEngine.Event.registerOut(EventOutTypes.onScriptVersionNotMatch, this, "onScriptVersionNotMatch");
}

public void onVersionNotMatch(string verInfo, string serVerInfo)
{
#if UNITY_EDITOR
if(automaticallyUpdateSDK)
gameObject.AddComponent<ClientSDKUpdater>();
#endif
}

public void onScriptVersionNotMatch(string verInfo, string serVerInfo)
{
#if UNITY_EDITOR
if(automaticallyUpdateSDK)
gameObject.AddComponent<ClientSDKUpdater>();
#endif
}

public virtual void initKBEngine()
{
// 如果此处发生错误,请查看 Assets\Scripts\kbe_scripts\if_Entity_error_use______git_submodule_update_____kbengine_plugins_______open_this_file_and_I_will_tell_you.cs
Expand Down Expand Up @@ -88,6 +108,7 @@ protected virtual void OnDestroy()
KBEngineApp.app.destroy();
KBEngineApp.app = null;
}
KBEngine.Event.clear();
MonoBehaviour.print("clientapp::OnDestroy(): end");
}

Expand Down
Loading

0 comments on commit d4f2d81

Please sign in to comment.