From 30852f812cae51cb7bfee4182dce518738ce5613 Mon Sep 17 00:00:00 2001 From: liuxq Date: Mon, 19 Dec 2016 23:14:30 +0800 Subject: [PATCH] =?UTF-8?q?kbe=E5=8D=87=E7=BA=A7=E5=88=B00.9.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/StriveGame/Lua/KbePlugins/Bundle.lua | 2 +- Assets/StriveGame/Lua/KbePlugins/KBEngine.lua | 56 ++-- Assets/StriveGame/Lua/KbePlugins/Message.lua | 7 +- Assets/StriveGame/Scripts/Common/LuaLoader.cs | 2 +- .../kbengine_unity3d_plugins-0.8.10/README.md | 310 ------------------ .../README.md.meta | 8 - ...ta => kbengine_unity3d_plugins-0.9.7.meta} | 4 +- .../Dbg.cs | 0 .../Dbg.cs.meta | 0 .../Event.cs | 0 .../Event.cs.meta | 0 .../KBEMain.cs | 0 .../KBEMain.cs.meta | 0 .../MemoryStream.cs | 0 .../MemoryStream.cs.meta | 0 .../NetworkInterface.cs | 48 ++- .../NetworkInterface.cs.meta | 0 .../PacketReceiver.cs | 0 .../PacketReceiver.cs.meta | 0 .../PacketSender.cs | 31 +- .../PacketSender.cs.meta | 0 .../PersistentInofs.cs | 0 .../PersistentInofs.cs.meta | 0 .../Profile.cs | 0 .../Profile.cs.meta | 0 25 files changed, 72 insertions(+), 396 deletions(-) delete mode 100644 Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/README.md delete mode 100644 Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/README.md.meta rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10.meta => kbengine_unity3d_plugins-0.9.7.meta} (67%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/Dbg.cs (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/Dbg.cs.meta (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/Event.cs (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/Event.cs.meta (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/KBEMain.cs (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/KBEMain.cs.meta (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/MemoryStream.cs (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/MemoryStream.cs.meta (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/NetworkInterface.cs (90%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/NetworkInterface.cs.meta (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/PacketReceiver.cs (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/PacketReceiver.cs.meta (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/PacketSender.cs (85%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/PacketSender.cs.meta (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/PersistentInofs.cs (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/PersistentInofs.cs.meta (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/Profile.cs (100%) rename Assets/StriveGame/Scripts/{kbengine_unity3d_plugins-0.8.10 => kbengine_unity3d_plugins-0.9.7}/Profile.cs.meta (100%) diff --git a/Assets/StriveGame/Lua/KbePlugins/Bundle.lua b/Assets/StriveGame/Lua/KbePlugins/Bundle.lua index f0bce3d..c9f3a93 100644 --- a/Assets/StriveGame/Lua/KbePlugins/Bundle.lua +++ b/Assets/StriveGame/Lua/KbePlugins/Bundle.lua @@ -78,7 +78,7 @@ function KBEngineLua.Bundle:send() if(networkInterface:valid()) then for i = 1, #self.streamList, 1 do self.stream = self.streamList[i]; - networkInterface:send(self.stream:getbuffer()); + networkInterface:send(self.stream); end else log("Bundle::send: networkInterface invalid!"); diff --git a/Assets/StriveGame/Lua/KbePlugins/KBEngine.lua b/Assets/StriveGame/Lua/KbePlugins/KBEngine.lua index 22371a2..ecb2f05 100644 --- a/Assets/StriveGame/Lua/KbePlugins/KBEngine.lua +++ b/Assets/StriveGame/Lua/KbePlugins/KBEngine.lua @@ -66,7 +66,7 @@ KBEngineLua._clientdatas = {}; KBEngineLua._encryptedKey = ""; -- 服务端与客户端的版本号以及协议MD5 -KBEngineLua.clientVersion = "0.8.10"; +KBEngineLua.clientVersion = "0.9.0"; KBEngineLua.clientScriptVersion = "0.1.0"; KBEngineLua.serverVersion = ""; KBEngineLua.serverScriptVersion = ""; @@ -81,7 +81,7 @@ KBEngineLua.entityIDAliasIDList = {}; KBEngineLua.bufferedCreateEntityMessage = {}; -- 持久化 -KBEngineLua._persistentInofs = nil; +KBEngineLua._persistentInfos = nil; -- 是否正在加载本地消息协议 KBEngineLua.loadingLocalMessages_ = false; @@ -116,7 +116,7 @@ end KBEngineLua.InitEngine = function() this._networkInterface = KBEngine.NetworkInterface.New(); KBEngineLua.Message.bindFixedMessage(); - this._persistentInofs = KBEngine.PersistentInofs.New(Util.DataPath); + this._persistentInfos = KBEngine.PersistentInofs.New(Util.DataPath); FixedUpdateBeat:Add(this.process, this); end @@ -252,8 +252,8 @@ end KBEngineLua.Client_onImportClientEntityDef = function(stream) local datas = stream:getbuffer(); this.onImportClientEntityDef(stream); - if(this._persistentInofs ~= nil) then - this._persistentInofs:onImportClientEntityDef(datas); + if(this._persistentInfos ~= nil) then + this._persistentInfos:onImportClientEntityDef(datas); end end @@ -262,19 +262,19 @@ KBEngineLua.onImportClientEntityDef = function(stream) while(stream:length() > 0) do - local scriptmethod_name = stream:readString(); + local scriptmodule_name = stream:readString(); local scriptUtype = stream:readUint16(); local propertysize = stream:readUint16(); local methodsize = stream:readUint16(); local base_methodsize = stream:readUint16(); local cell_methodsize = stream:readUint16(); - log("KBEngineApp::Client_onImportClientEntityDef: import(" .. scriptmethod_name .. "), propertys(" .. propertysize .. "), " .. + log("KBEngineApp::Client_onImportClientEntityDef: import(" .. scriptmodule_name .. "), propertys(" .. propertysize .. "), " .. "clientMethods(" .. methodsize .. "), baseMethods(" .. base_methodsize .. "), cellMethods(" .. cell_methodsize .. ")~"); - KBEngineLua.moduledefs[scriptmethod_name] = {}; - local currModuleDefs = KBEngineLua.moduledefs[scriptmethod_name]; - currModuleDefs["name"] = scriptmethod_name; + KBEngineLua.moduledefs[scriptmodule_name] = {}; + local currModuleDefs = KBEngineLua.moduledefs[scriptmodule_name]; + currModuleDefs["name"] = scriptmodule_name; currModuleDefs["propertys"] = {}; currModuleDefs["methods"] = {}; currModuleDefs["base_methods"] = {}; @@ -286,7 +286,7 @@ KBEngineLua.onImportClientEntityDef = function(stream) local self_base_methods = currModuleDefs["base_methods"]; local self_cell_methods= currModuleDefs["cell_methods"]; - local Class = KBEngineLua[scriptmethod_name]; + local Class = KBEngineLua[scriptmodule_name]; while(propertysize > 0) do @@ -314,7 +314,7 @@ KBEngineLua.onImportClientEntityDef = function(stream) currModuleDefs["usePropertyDescrAlias"] = false; end - log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmethod_name .. "), property(" .. name .. "/" .. properUtype .. ")."); + log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmodule_name .. "), property(" .. name .. "/" .. properUtype .. ")."); end while(methodsize > 0) do @@ -343,7 +343,7 @@ KBEngineLua.onImportClientEntityDef = function(stream) currModuleDefs["useMethodDescrAlias"] = false; end - log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmethod_name .. "), method(" .. name .. ")."); + log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmodule_name .. "), method(" .. name .. ")."); end while(base_methodsize > 0) @@ -363,7 +363,7 @@ KBEngineLua.onImportClientEntityDef = function(stream) end self_base_methods[name] = {methodUtype, aliasID, name, args}; - log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmethod_name .. "), base_method(" .. name .. ")."); + log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmodule_name .. "), base_method(" .. name .. ")."); end while(cell_methodsize > 0) @@ -383,12 +383,12 @@ KBEngineLua.onImportClientEntityDef = function(stream) end self_cell_methods[name] = {methodUtype, aliasID, name, args}; - log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmethod_name .. "), cell_method(" .. name .. ")."); + log("KBEngineApp::Client_onImportClientEntityDef: add(" .. scriptmodule_name .. "), cell_method(" .. name .. ")."); end - defmethod = KBEngineLua[scriptmethod_name]; + defmethod = KBEngineLua[scriptmodule_name]; if defmethod == nil then - log("KBEngineApp::Client_onImportClientEntityDef: module(" .. scriptmethod_name .. ") not found~"); + log("KBEngineApp::Client_onImportClientEntityDef: module(" .. scriptmodule_name .. ") not found~"); end for k, value in pairs(currModuleDefs.propertys) do @@ -412,7 +412,7 @@ KBEngineLua.onImportClientEntityDef = function(stream) local args = infos[4]; if(defmethod ~= nil and defmethod[name] == nil) then - log(scriptmethod_name .. ":: method(" .. name .. ") no implement~"); + log(scriptmodule_name .. ":: method(" .. name .. ") no implement~"); end end end @@ -423,8 +423,8 @@ KBEngineLua.Client_onImportClientMessages = function( stream ) local datas = stream:getbuffer(); this.onImportClientMessages (stream); - if(this._persistentInofs ~= nil) then - this._persistentInofs:onImportClientMessages(this.currserver, datas); + if(this._persistentInfos ~= nil) then + this._persistentInfos:onImportClientMessages(this.currserver, datas); end end @@ -480,8 +480,8 @@ KBEngineLua.Client_onImportServerErrorsDescr = function(stream) local datas = stream:getbuffer(); this.onImportServerErrorsDescr(stream); - if(this._persistentInofs ~= nil) then - this._persistentInofs:onImportServerErrorsDescr(datas); + if(this._persistentInfos ~= nil) then + this._persistentInfos:onImportServerErrorsDescr(datas); end end @@ -1486,8 +1486,8 @@ KBEngineLua.Client_onHelloCB = function( stream ) end KBEngineLua.onServerDigest = function() - if this._persistentInofs ~= nil then - this._persistentInofs:onServerDigest(this.currserver, this.serverProtocolMD5, this.serverEntitydefMD5); + if this._persistentInfos ~= nil then + this._persistentInfos:onServerDigest(this.currserver, this.serverProtocolMD5, this.serverEntitydefMD5); end end @@ -1752,8 +1752,8 @@ KBEngineLua.Client_onVersionNotMatch = function(stream) log("Client_onVersionNotMatch: verInfo=" .. this.clientVersion .. "(server: " .. this.serverVersion .. ")"); --Event.fireAll("onVersionNotMatch", new object[]{clientVersion, serverVersion}); - if(this._persistentInofs ~= nil) then - this._persistentInofs:onVersionNotMatch(this.clientVersion, this.serverVersion); + if(this._persistentInfos ~= nil) then + this._persistentInfos:onVersionNotMatch(this.clientVersion, this.serverVersion); end end @@ -1765,8 +1765,8 @@ KBEngineLua.Client_onScriptVersionNotMatch = function(stream) log("Client_onScriptVersionNotMatch: verInfo=" .. this.clientScriptVersion .. "(server: " .. this.serverScriptVersion .. ")"); --Event.fireAll("onScriptVersionNotMatch", new object[]{clientScriptVersion, this.serverScriptVersion}); - if(_persistentInofs ~= nil) then - _persistentInofs.onScriptVersionNotMatch(this.clientScriptVersion, this.serverScriptVersion); + if(_persistentInfos ~= nil) then + _persistentInfos.onScriptVersionNotMatch(this.clientScriptVersion, this.serverScriptVersion); end end diff --git a/Assets/StriveGame/Lua/KbePlugins/Message.lua b/Assets/StriveGame/Lua/KbePlugins/Message.lua index 4d9ff3f..5fa1526 100644 --- a/Assets/StriveGame/Lua/KbePlugins/Message.lua +++ b/Assets/StriveGame/Lua/KbePlugins/Message.lua @@ -139,7 +139,12 @@ function KBEngineLua.MessageReader.process(datas, offset, length) if(msg.msglen == -1) then reader.state = KBEngineLua.READ_STATE_MSGLEN; reader.expectSize = 2; - else + elseif(msg.msglen == 0) then + -- 如果是0个参数的消息,那么没有后续内容可读了,处理本条消息并且直接跳到下一条消息 + msg:handleMessage(stream); + state = KBEngineLua.READ_STATE_MSGID; + expectSize = 2; + else reader.expectSize = msg.msglen; reader.state = KBEngineLua.READ_STATE_BODY; end diff --git a/Assets/StriveGame/Scripts/Common/LuaLoader.cs b/Assets/StriveGame/Scripts/Common/LuaLoader.cs index 9fbef77..a0ffc65 100644 --- a/Assets/StriveGame/Scripts/Common/LuaLoader.cs +++ b/Assets/StriveGame/Scripts/Common/LuaLoader.cs @@ -31,7 +31,7 @@ public LuaLoader() { public void AddBundle(string bundleName) { string url = Util.DataPath + bundleName.ToLower(); if (File.Exists(url)) { - AssetBundle bundle = AssetBundle.CreateFromFile(url); + AssetBundle bundle = AssetBundle.LoadFromFile(url); if (bundle != null) { bundleName = bundleName.Replace("lua/", "").Replace(".unity3d", ""); diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/README.md b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/README.md deleted file mode 100644 index e7fbd18..0000000 --- a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/README.md +++ /dev/null @@ -1,310 +0,0 @@ -kbengine_unity3d_plugins -======================== - -Usage ---------------------- - - 1: Create clientapp.cs - using KBEngine; - public class clientapp : KBEMain - { - } - - 2: Implment the KBE defined entity (including the client part) - See: kbengine\kbengine_demos_assets\scripts\entities.xmlhasClient="true" need to implment - - - - - - public class Account : KBEngine.GameObject - { - // entity initialization - public override void __init__() - { - } - } - - Call entity server method - entity.baseCall("base_func", 1, "arg2", "argN") - entity.cellCall("cell_func", 1, "arg2", "argN") - - 3: Monitor KBE-plugins event - public class UI : MonoBehaviour - { - void Start () - { - KBEngine.Event.registerOut("onConnectStatus", this, "onConnectStatus"); - } - - public void onConnectStatus(bool success) - { - // KBE-plugins event fired - } - } - - 4: Fire events to the KBE-plugins - KBEngine.Event.fireIn("login", "stringAccount", "stringPasswd", System.Text.Encoding.UTF8.GetBytes("kbengine_unity3d_demo")); - - - -KBE-Plugin fire-out events(KBE => Unity): ---------------------- - - Entity events: - onEnterWorld - Description: - Entity enter the client-world. - - Event-datas: - Enity - - - onLeaveWorld - Description: - Entity leave the client-world. - - Event-datas: - Enity - - onEnterSpace - Description: - Player enter the new space. - - Event-datas: - Enity - - onLeaveSpace - Description: - Player enter the space. - - Event-datas: - Enity - - onCreateAccountResult - Description: - Create account feedback results. - - Event-datas: - uint16: retcode - http://kbengine.org/docs/configuration/server_errors.html - - bytes: datas - If you use third-party account system, the system may fill some of the third-party additional datas. - - set_position - Description: - Sets the current position of the entity. - - Event-datas: - Enity - - set_direction - Description: - Sets the current direction of the entity. - - Event-datas: - Enity - - updatePosition - Description: - The entity position is updated, you can smooth the moving entity to new location. - - Event-datas: - Enity - - Protocol events: - onVersionNotMatch - Description: - Engine version mismatch. - - Event-datas: - string: clientVersion - string: serverVersion - - onScriptVersionNotMatch - Description: - script version mismatch. - - Event-datas: - string: clientScriptVersion - string: serverScriptVersion - - Loginapp_importClientMessages - Description: - Importing the message protocol for loginapp and client. - - Event-datas: - No datas. - - Baseapp_importClientMessages - Description: - Importing the message protocol for baseapp and client. - - Event-datas: - No datas. - - Baseapp_importClientEntityDef - Description: - Protocol description for importing entities. - - Event-datas: - No datas. - - Login and Logout status: - onLoginBaseapp - Description: - Login to baseapp. - - Event-datas: - No datas. - - onReLoginBaseapp - Description: - Relogin to baseapp. - - Event-datas: - No datas. - - onKicked - Description: - Kicked of the current server. - - Event-datas: - uint16: retcode - http://kbengine.org/docs/configuration/server_errors.html - - onLoginFailed - Description: - Login failed. - - Event-datas: - uint16: retcode - http://kbengine.org/docs/configuration/server_errors.html - - onLoginBaseappFailed - Description: - Login baseapp failed. - - Event-datas: - uint16: retcode - http://kbengine.org/docs/configuration/server_errors.html - - onReLoginBaseappFailed - Description: - Relogin baseapp failed. - - Event-datas: - uint16: retcode - http://kbengine.org/docs/configuration/server_errors.html - - onReLoginBaseappSuccessfully - Description: - Relogin baseapp success. - - Event-datas: - No datas. - - Space events: - addSpaceGeometryMapping - Description: - The current space is specified by the geometry mapping. - Popular said is to load the specified Map Resources. - - Event-datas: - string: resPath - - onSetSpaceData - Description: - Server spaceData set data. - - Event-datas: - int32: spaceID - string: key - string value - - onDelSpaceData - Description: - Server spaceData delete data. - - Event-datas: - int32: spaceID - string: key - - Network events: - onConnectStatus - Description: - Status of connection server. - - Event-datas: - bool: success or fail - - onDisableConnect - Description: - Status of connection server. - - Event-datas: - No datas. - - - -KBE-Plugin fire-in events(Unity => KBE): ---------------------- - - createAccount - Description: - Create new account. - - Event-datas: - string: accountName - string: password - bytes: datas - Datas by user defined. - Data will be recorded into the KBE account database, you can access the datas through the script layer. - If you use third-party account system, datas will be submitted to the third-party system. - - - login - Description: - Login to server. - - Event-datas: - string: accountName - string: password - bytes: datas - Datas by user defined. - Data will be recorded into the KBE account database, you can access the datas through the script layer. - If you use third-party account system, datas will be submitted to the third-party system. - - reLoginBaseapp - Description: - Relogin to baseapp. - - Event-datas: - No datas. - - resetPassword - Description: - Reset password. - - Event-datas: - string: accountName - - newPassword - Description: - Request to set up a new password for the account. - Note: account must be online - - Event-datas: - string: old_password - string: new_password - - bindAccountEmail - Description: - Request server binding account Email. - Note: account must be online - - Event-datas: - string: emailAddress - - diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/README.md.meta b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/README.md.meta deleted file mode 100644 index d073bcd..0000000 --- a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/README.md.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c98964918aac78946902ce280152ebf9 -timeCreated: 1457687534 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10.meta b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7.meta similarity index 67% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10.meta rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7.meta index 5286182..85c1a05 100644 --- a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10.meta +++ b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 -guid: dcee0af02ea41bf4a8434b93e6f062b8 +guid: a51fbc42b757b2946ad8355f72e5c23d folderAsset: yes -timeCreated: 1467703808 +timeCreated: 1482076801 licenseType: Free DefaultImporter: userData: diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/Dbg.cs b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/Dbg.cs similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/Dbg.cs rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/Dbg.cs diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/Dbg.cs.meta b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/Dbg.cs.meta similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/Dbg.cs.meta rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/Dbg.cs.meta diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/Event.cs b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/Event.cs similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/Event.cs rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/Event.cs diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/Event.cs.meta b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/Event.cs.meta similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/Event.cs.meta rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/Event.cs.meta diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/KBEMain.cs b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/KBEMain.cs similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/KBEMain.cs rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/KBEMain.cs diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/KBEMain.cs.meta b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/KBEMain.cs.meta similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/KBEMain.cs.meta rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/KBEMain.cs.meta diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/MemoryStream.cs b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/MemoryStream.cs similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/MemoryStream.cs rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/MemoryStream.cs diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/MemoryStream.cs.meta b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/MemoryStream.cs.meta similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/MemoryStream.cs.meta rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/MemoryStream.cs.meta diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/NetworkInterface.cs b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/NetworkInterface.cs similarity index 90% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/NetworkInterface.cs rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/NetworkInterface.cs index 98fa56e..c1919c9 100644 --- a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/NetworkInterface.cs +++ b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/NetworkInterface.cs @@ -193,36 +193,26 @@ public void close() _socket = null; } - public bool send(byte[] datas) - { - if(!valid()) + public bool send(MemoryStream stream) + { + if (!valid()) { - throw new ArgumentException ("invalid socket!"); + throw new ArgumentException("invalid socket!"); } - - if(_packetSender == null) + + if (_packetSender == null) _packetSender = new PacketSender(this); - - try - { - return _packetSender.send(datas); - } - catch (SocketException err) - { - Dbg.ERROR_MSG(string.Format("NetworkInterface::send(): socket error(" + err.ErrorCode + ")!")); - close(); - } - - return false; - } - - public void process() - { - if(!valid()) - return; - - if(_packetReceiver != null) - _packetReceiver.process(); - } + + return _packetSender.send(stream); + } + + public void process() + { + if (!valid()) + return; + + if (_packetReceiver != null) + _packetReceiver.process(); + } } -} +} diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/NetworkInterface.cs.meta b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/NetworkInterface.cs.meta similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/NetworkInterface.cs.meta rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/NetworkInterface.cs.meta diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PacketReceiver.cs b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PacketReceiver.cs similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PacketReceiver.cs rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PacketReceiver.cs diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PacketReceiver.cs.meta b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PacketReceiver.cs.meta similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PacketReceiver.cs.meta rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PacketReceiver.cs.meta diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PacketSender.cs b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PacketSender.cs similarity index 85% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PacketSender.cs rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PacketSender.cs index 60c1e4f..31bb95a 100644 --- a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PacketSender.cs +++ b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PacketSender.cs @@ -53,17 +53,16 @@ public NetworkInterface networkInterface() { return _networkInterface; } - - public bool send(byte[] datas) + + public bool send(MemoryStream stream) { - if(datas.Length <= 0) + int dataLength = (int)stream.length(); + if (dataLength <= 0) return true; - bool startSend = false; - if(Interlocked.CompareExchange(ref _sending, 1, 0) == 0) + if (0 == Interlocked.Add(ref _sending, 0)) { - startSend = true; - if(_wpos == _spos) + if (_wpos == _spos) { _wpos = 0; _spos = 0; @@ -80,36 +79,36 @@ public bool send(byte[] datas) else space = tt_spos - tt_wpos - 1; - if (datas.Length > space) + if (dataLength > space) { - Dbg.ERROR_MSG("PacketSender::send(): no space, Please adjust 'SEND_BUFFER_MAX'! data(" + datas.Length + Dbg.ERROR_MSG("PacketSender::send(): no space, Please adjust 'SEND_BUFFER_MAX'! data(" + dataLength + ") > space(" + space + "), wpos=" + _wpos + ", spos=" + t_spos); return false; } - int expect_total = tt_wpos + datas.Length; + int expect_total = tt_wpos + dataLength; if(expect_total <= _buffer.Length) { - Array.Copy(datas, 0, _buffer, tt_wpos, datas.Length); + Array.Copy(stream.data(), stream.rpos, _buffer, tt_wpos, dataLength); } else { int remain = _buffer.Length - tt_wpos; - Array.Copy(datas, 0, _buffer, tt_wpos, remain); - Array.Copy(datas, remain, _buffer, 0, expect_total - _buffer.Length); + Array.Copy(stream.data(), stream.rpos, _buffer, tt_wpos, remain); + Array.Copy(stream.data(), stream.rpos + remain, _buffer, 0, expect_total - _buffer.Length); } - Interlocked.Add(ref _wpos, datas.Length); + Interlocked.Add(ref _wpos, dataLength); - if(startSend) + if (Interlocked.CompareExchange(ref _sending, 1, 0) == 0) { _startSend(); } return true; } - + void _startSend() { int sendSize = Interlocked.Add(ref _wpos, 0) - _spos; diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PacketSender.cs.meta b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PacketSender.cs.meta similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PacketSender.cs.meta rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PacketSender.cs.meta diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PersistentInofs.cs b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PersistentInofs.cs similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PersistentInofs.cs rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PersistentInofs.cs diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PersistentInofs.cs.meta b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PersistentInofs.cs.meta similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/PersistentInofs.cs.meta rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/PersistentInofs.cs.meta diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/Profile.cs b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/Profile.cs similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/Profile.cs rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/Profile.cs diff --git a/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/Profile.cs.meta b/Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/Profile.cs.meta similarity index 100% rename from Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.8.10/Profile.cs.meta rename to Assets/StriveGame/Scripts/kbengine_unity3d_plugins-0.9.7/Profile.cs.meta