Ejemplo n.º 1
0
        public D_HERO_INFOS createFromStreamEx(MemoryStream stream)
        {
            D_HERO_INFOS datas = new D_HERO_INFOS();

            datas.id                = stream.readInt32();
            datas.name              = stream.readString();
            datas.nick_name         = stream.readUnicode();
            datas.race              = stream.readInt32();
            datas.race_desc         = stream.readUnicode();
            datas.skill_1           = stream.readInt32();
            datas.skill_2           = stream.readInt32();
            datas.skill_3           = stream.readInt32();
            datas.skill_4           = stream.readInt32();
            datas.hero_hp           = stream.readInt32();
            datas.hero_mp           = stream.readInt32();
            datas.hero_strength     = stream.readInt32();
            datas.hero_agile        = stream.readInt32();
            datas.hero_intelligence = stream.readInt32();
            datas.hero_attacktime   = stream.readInt32();
            datas.hero_speed        = stream.readInt32();
            datas.hero_attackfront  = stream.readInt32();
            datas.hero_attackback   = stream.readInt32();
            datas.hero_skillfront   = stream.readInt32();
            datas.hero_skillback    = stream.readInt32();
            datas.hero_scope        = stream.readInt32();
            datas.hero_attack       = stream.readInt32();
            datas.hero_armor        = stream.readInt32();
            datas.hero_unarmor      = stream.readInt32();
            datas.hero_magic        = stream.readInt32();
            datas.hero_magicresist  = stream.readInt32();
            datas.hero_hprestored   = stream.readInt32();
            datas.hero_mprestored   = stream.readInt32();
            datas.hero_crit         = stream.readInt32();
            datas.hero_uncrit       = stream.readInt32();
            datas.hero_critunmber   = stream.readInt32();
            datas.hero_evade        = stream.readInt32();
            datas.hero_unevade      = stream.readInt32();
            datas.hero_parry        = stream.readInt32();
            datas.hero_unparry      = stream.readInt32();
            datas.hero_parrynumber  = stream.readInt32();
            datas.hero_xixue        = stream.readInt32();
            datas.atk_power         = stream.readInt32();
            datas.hurt_power        = stream.readInt32();
            datas.kill_power        = stream.readInt32();
            datas.hero_energe       = stream.readInt32();
            datas.head_icon         = stream.readString();
            return(datas);
        }
Ejemplo n.º 2
0
        public D_PROPS_INFOS createFromStreamEx(MemoryStream stream)
        {
            D_PROPS_INFOS datas = new D_PROPS_INFOS();

            datas.prop_id          = stream.readInt32();
            datas.prop_name        = stream.readUnicode();
            datas.prop_icon        = stream.readString();
            datas.prop_type        = stream.readInt32();
            datas.prop_quality     = stream.readInt32();
            datas.prop_order       = stream.readInt32();
            datas.prop_max         = stream.readInt32();
            datas.prop_resale      = stream.readInt32();
            datas.prop_diamond     = stream.readInt32();
            datas.prop_hanbing     = stream.readInt32();
            datas.prop_moba        = stream.readInt32();
            datas.prop_jjc         = stream.readInt32();
            datas.prop_maoxian     = stream.readInt32();
            datas.prop_describe    = stream.readUnicode();
            datas.prop_function    = stream.readInt32();
            datas.prop_parameters1 = stream.readInt32();
            datas.prop_parameters2 = stream.readInt32();
            datas.prop_parameters3 = stream.readInt32();
            datas.prop_parameters4 = stream.readInt32();
            datas.prop_parameters5 = stream.readInt32();
            datas.prop_parameters6 = stream.readInt32();
            datas.prop_drop1       = stream.readInt32();
            datas.prop_drop2       = stream.readInt32();
            datas.prop_drop3       = stream.readInt32();
            datas.prop_drop4       = stream.readInt32();
            datas.prop_gm          = stream.readInt32();
            datas.prop_buy         = stream.readInt32();
            return(datas);
        }
Ejemplo n.º 3
0
 static int readString(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         KBEngine.MemoryStream obj = (KBEngine.MemoryStream)ToLua.CheckObject <KBEngine.MemoryStream>(L, 1);
         string o = obj.readString();
         LuaDLL.lua_pushstring(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 4
0
        public D_SHOP_INFOS createFromStreamEx(MemoryStream stream)
        {
            D_SHOP_INFOS datas = new D_SHOP_INFOS();

            datas.shop_id           = stream.readInt32();
            datas.shop_des          = stream.readUnicode();
            datas.shop_refreshstart = stream.readInt32();
            datas.shop_refreshtime  = stream.readInt32();
            datas.shop_needid       = stream.readInt32();
            datas.shop_needdes      = stream.readUnicode();
            datas.shop_amount       = stream.readInt32();
            datas.shop_refreshtime1 = stream.readString();
            datas.open_lv           = stream.readInt32();
            return(datas);
        }
Ejemplo n.º 5
0
        public override void onRemoteMethodCall(UInt16 methodUtype, MemoryStream stream)
        {
            ScriptModule sm = EntityDef.moduledefs["Chat"];

            Method method = sm.idmethods[methodUtype];

            switch (method.methodUtype)
            {
            case 28:
                string reply_arg1 = stream.readString();
                string reply_arg2 = stream.readUnicode();
                reply(reply_arg1, reply_arg2);
                break;

            default:
                break;
            }
            ;
        }
Ejemplo n.º 6
0
        public D_SKILL_INFOS createFromStreamEx(MemoryStream stream)
        {
            D_SKILL_INFOS datas = new D_SKILL_INFOS();

            datas.id                  = stream.readInt32();
            datas.name                = stream.readUnicode();
            datas.skill_icon          = stream.readString();
            datas.skill_damage_chushi = stream.readInt32();
            datas.skill_damage_growth = stream.readInt32();
            datas.skill_ad_chushi     = stream.readInt32();
            datas.skill_ad_growth     = stream.readInt32();
            datas.skill_ap_chushi     = stream.readInt32();
            datas.skill_ap_growth     = stream.readInt32();
            datas.skill_type          = stream.readInt32();
            datas.skill_ongoing       = stream.readInt32();
            datas.skill_sing_time     = stream.readInt32();
            datas.skill_cutdown       = stream.readInt32();
            datas.skill_cutdownif     = stream.readInt32();
            datas.skill_cd            = stream.readInt32();
            datas.attack_distance     = stream.readInt32();
            datas.aoe_radius          = stream.readInt32();
            return(datas);
        }
Ejemplo n.º 7
0
        public void onImportClientEntityDef(MemoryStream stream)
        {
            createDataTypeFromStreams(stream, true);

            while(stream.length() > 0)
            {
                string scriptmethod_name = stream.readString();
                UInt16 scriptUtype = stream.readUint16();
                UInt16 propertysize = stream.readUint16();
                UInt16 methodsize = stream.readUint16();
                UInt16 base_methodsize = stream.readUint16();
                UInt16 cell_methodsize = stream.readUint16();

                Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: import(" + scriptmethod_name + "), propertys(" + propertysize + "), " +
                        "clientMethods(" + methodsize + "), baseMethods(" + base_methodsize + "), cellMethods(" + cell_methodsize + ")!");

                ScriptModule module = new ScriptModule(scriptmethod_name);
                EntityDef.moduledefs[scriptmethod_name] = module;
                EntityDef.idmoduledefs[scriptUtype] = module;

                Type Class = module.script;

                while(propertysize > 0)
                {
                    propertysize--;

                    UInt16 properUtype = stream.readUint16();
                    UInt32 properFlags = stream.readUint32();
                    Int16 ialiasID = stream.readInt16();
                    string name = stream.readString();
                    string defaultValStr = stream.readString();
                    KBEDATATYPE_BASE utype = EntityDef.id2datatypes[stream.readUint16()];

                    System.Reflection.MethodInfo setmethod = null;

                    if(Class != null)
                    {
                        try{
                            setmethod = Class.GetMethod("set_" + name);
                        }
                        catch (Exception e)
                        {
                            string err = "KBEngine::Client_onImportClientEntityDef: " +
                                scriptmethod_name + ".set_" + name + ", error=" + e.ToString();

                            throw new Exception(err);
                        }
                    }

                    Property savedata = new Property();
                    savedata.name = name;
                    savedata.utype = utype;
                    savedata.properUtype = properUtype;
                    savedata.properFlags = properFlags;
                    savedata.aliasID = ialiasID;
                    savedata.defaultValStr = defaultValStr;
                    savedata.setmethod = setmethod;
                    savedata.val = savedata.utype.parseDefaultValStr(savedata.defaultValStr);

                    module.propertys[name] = savedata;

                    if(ialiasID >= 0)
                    {
                        module.usePropertyDescrAlias = true;
                        module.idpropertys[(UInt16)ialiasID] = savedata;
                    }
                    else
                    {
                        module.usePropertyDescrAlias = false;
                        module.idpropertys[properUtype] = savedata;
                    }

                    //Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: add(" + scriptmethod_name + "), property(" + name + "/" + properUtype + ").");
                };

                while(methodsize > 0)
                {
                    methodsize--;

                    UInt16 methodUtype = stream.readUint16();
                    Int16 ialiasID = stream.readInt16();
                    string name = stream.readString();
                    Byte argssize = stream.readUint8();
                    List<KBEDATATYPE_BASE> args = new List<KBEDATATYPE_BASE>();

                    while(argssize > 0)
                    {
                        argssize--;
                        args.Add(EntityDef.id2datatypes[stream.readUint16()]);
                    };

                    Method savedata = new Method();
                    savedata.name = name;
                    savedata.methodUtype = methodUtype;
                    savedata.aliasID = ialiasID;
                    savedata.args = args;

                    if(Class != null)
                    {
                        try{
                            savedata.handler = Class.GetMethod(name);
                        }
                        catch (Exception e)
                        {
                            string err = "KBEngine::Client_onImportClientEntityDef: " + scriptmethod_name + "." + name + ", error=" + e.ToString();
                            throw new Exception(err);
                        }
                    }

                    module.methods[name] = savedata;

                    if(ialiasID >= 0)
                    {
                        module.useMethodDescrAlias = true;
                        module.idmethods[(UInt16)ialiasID] = savedata;
                    }
                    else
                    {
                        module.useMethodDescrAlias = false;
                        module.idmethods[methodUtype] = savedata;
                    }

                    //Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: add(" + scriptmethod_name + "), method(" + name + ").");
                };

                while(base_methodsize > 0)
                {
                    base_methodsize--;

                    UInt16 methodUtype = stream.readUint16();
                    Int16 ialiasID = stream.readInt16();
                    string name = stream.readString();
                    Byte argssize = stream.readUint8();
                    List<KBEDATATYPE_BASE> args = new List<KBEDATATYPE_BASE>();

                    while(argssize > 0)
                    {
                        argssize--;
                        args.Add(EntityDef.id2datatypes[stream.readUint16()]);
                    };

                    Method savedata = new Method();
                    savedata.name = name;
                    savedata.methodUtype = methodUtype;
                    savedata.aliasID = ialiasID;
                    savedata.args = args;

                    module.base_methods[name] = savedata;
                    module.idbase_methods[methodUtype] = savedata;

                    //Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: add(" + scriptmethod_name + "), base_method(" + name + ").");
                };

                while(cell_methodsize > 0)
                {
                    cell_methodsize--;

                    UInt16 methodUtype = stream.readUint16();
                    Int16 ialiasID = stream.readInt16();
                    string name = stream.readString();
                    Byte argssize = stream.readUint8();
                    List<KBEDATATYPE_BASE> args = new List<KBEDATATYPE_BASE>();

                    while(argssize > 0)
                    {
                        argssize--;
                        args.Add(EntityDef.id2datatypes[stream.readUint16()]);
                    };

                    Method savedata = new Method();
                    savedata.name = name;
                    savedata.methodUtype = methodUtype;
                    savedata.aliasID = ialiasID;
                    savedata.args = args;

                    module.cell_methods[name] = savedata;
                    module.idcell_methods[methodUtype] = savedata;
                    //Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: add(" + scriptmethod_name + "), cell_method(" + name + ").");
                };

                if(module.script == null)
                {
                    Dbg.ERROR_MSG("KBEngine::Client_onImportClientEntityDef: module(" + scriptmethod_name + ") not found!");
                }

                foreach(string name in module.methods.Keys)
                {
                    // Method infos = module.methods[name];

                    if(module.script != null && module.script.GetMethod(name) == null)
                    {
                        Dbg.WARNING_MSG(scriptmethod_name + "(" + module.script + "):: method(" + name + ") no implement!");
                    }
                };
            }

            onImportEntityDefCompleted();
        }
Ejemplo n.º 8
0
        public void createDataTypeFromStream(MemoryStream stream, bool canprint)
        {
            UInt16 utype = stream.readUint16();
            string name = stream.readString();
            string valname = stream.readString();

            /* 有一些匿名类型,我们需要提供一个唯一名称放到datatypes中
                如:
                <onRemoveAvatar>
                    <Arg>	ARRAY <of> INT8 </of>		</Arg>
                </onRemoveAvatar>
            */
            if(valname.Length == 0)
                valname = "Null_" + utype;

            if(canprint)
                Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: importAlias(" + name + ":" + valname + ":" + utype + ")!");

            if(name == "FIXED_DICT")
            {
                KBEDATATYPE_FIXED_DICT datatype = new KBEDATATYPE_FIXED_DICT();
                Byte keysize = stream.readUint8();
                datatype.implementedBy = stream.readString();

                while(keysize > 0)
                {
                    keysize--;

                    string keyname = stream.readString();
                    UInt16 keyutype = stream.readUint16();
                    datatype.dicttype[keyname] = keyutype;
                };

                EntityDef.datatypes[valname] = datatype;
            }
            else if(name == "ARRAY")
            {
                UInt16 uitemtype = stream.readUint16();
                KBEDATATYPE_ARRAY datatype = new KBEDATATYPE_ARRAY();
                datatype.vtype = uitemtype;
                EntityDef.datatypes[valname] = datatype;
            }
            else
            {
                KBEDATATYPE_BASE val = null;
                EntityDef.datatypes.TryGetValue(name, out val);
                EntityDef.datatypes[valname] = val;
            }

            EntityDef.id2datatypes[utype] = EntityDef.datatypes[valname];

            // 将用户自定义的类型补充到映射表中
            EntityDef.datatype2id[valname] = utype;
        }
Ejemplo n.º 9
0
        public void Client_onImportMercuryErrorsDescr(MemoryStream stream)
        {
            UInt16 size = stream.readUint16();
            while(size > 0)
            {
                size -= 1;

                MercuryErr e;
                e.id = stream.readUint16();
                e.name = stream.readString();
                e.descr = stream.readString();

                mercuryErrs.Add(e.id, e);

                Dbg.DEBUG_MSG("Client_onImportMercuryErrorsDescr: id=" + e.id + ", name=" + e.name + ", descr=" + e.descr);
            }
        }
Ejemplo n.º 10
0
        public void Client_onImportClientEntityDef(MemoryStream stream)
        {
            UInt16 aliassize = stream.readUint16();
            Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: importAlias(size=" + aliassize + ")!");

            while(aliassize > 0)
            {
                aliassize--;
                createDataTypeFromStream(stream, true);
            };

            foreach(string datatype in EntityDef.datatypes.Keys)
            {
                if(EntityDef.datatypes[datatype] != null)
                {
                    EntityDef.datatypes[datatype].bind();
                }
            }

            while(stream.opsize() > 0)
            {
                string scriptmethod_name = stream.readString();
                UInt16 scriptUtype = stream.readUint16();
                UInt16 propertysize = stream.readUint16();
                UInt16 methodsize = stream.readUint16();
                UInt16 base_methodsize = stream.readUint16();
                UInt16 cell_methodsize = stream.readUint16();

                Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: import(" + scriptmethod_name + "), propertys(" + propertysize + "), " +
                        "clientMethods(" + methodsize + "), baseMethods(" + base_methodsize + "), cellMethods(" + cell_methodsize + ")!");

                ScriptModule module = new ScriptModule(scriptmethod_name);
                EntityDef.moduledefs[scriptmethod_name] = module;
                EntityDef.idmoduledefs[scriptUtype] = module;

                Dictionary<string, Property> defpropertys = new Dictionary<string, Property>();
                Entity.alldefpropertys.Add(scriptmethod_name, defpropertys);

                Type Class = module.script;

                while(propertysize > 0)
                {
                    propertysize--;

                    UInt16 properUtype = stream.readUint16();
                    string name = stream.readString();
                    string defaultValStr = stream.readString();
                    KBEDATATYPE_BASE utype = EntityDef.iddatatypes[stream.readUint16()];

                    System.Reflection.MethodInfo setmethod = null;

                    if(Class != null)
                    {
                        setmethod = Class.GetMethod("set_" + name);
                    }

                    Property savedata = new Property();
                    savedata.name = name;
                    savedata.properUtype = properUtype;
                    savedata.defaultValStr = defaultValStr;
                    savedata.utype = utype;
                    savedata.setmethod = setmethod;

                    module.propertys[name] = savedata;
                    module.idpropertys[properUtype] = savedata;

                    Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: add(" + scriptmethod_name + "), property(" + name + "/" + properUtype + ").");
                };

                while(methodsize > 0)
                {
                    methodsize--;

                    UInt16 methodUtype = stream.readUint16();
                    string name = stream.readString();
                    Byte argssize = stream.readUint8();
                    List<KBEDATATYPE_BASE> args = new List<KBEDATATYPE_BASE>();

                    while(argssize > 0)
                    {
                        argssize--;
                        args.Add(EntityDef.iddatatypes[stream.readUint16()]);
                    };

                    Method savedata = new Method();
                    savedata.name = name;
                    savedata.methodUtype = methodUtype;
                    savedata.args = args;

                    if(Class != null)
                        savedata.handler = Class.GetMethod(name);

                    module.methods[name] = savedata;
                    module.idmethods[methodUtype] = savedata;
                    Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: add(" + scriptmethod_name + "), method(" + name + ").");
                };

                while(base_methodsize > 0)
                {
                    base_methodsize--;

                    UInt16 methodUtype = stream.readUint16();
                    string name = stream.readString();
                    Byte argssize = stream.readUint8();
                    List<KBEDATATYPE_BASE> args = new List<KBEDATATYPE_BASE>();

                    while(argssize > 0)
                    {
                        argssize--;
                        args.Add(EntityDef.iddatatypes[stream.readUint16()]);
                    };

                    Method savedata = new Method();
                    savedata.name = name;
                    savedata.methodUtype = methodUtype;
                    savedata.args = args;

                    module.base_methods[name] = savedata;
                    module.idbase_methods[methodUtype] = savedata;

                    Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: add(" + scriptmethod_name + "), base_method(" + name + ").");
                };

                while(cell_methodsize > 0)
                {
                    cell_methodsize--;

                    UInt16 methodUtype = stream.readUint16();
                    string name = stream.readString();
                    Byte argssize = stream.readUint8();
                    List<KBEDATATYPE_BASE> args = new List<KBEDATATYPE_BASE>();

                    while(argssize > 0)
                    {
                        argssize--;
                        args.Add(EntityDef.iddatatypes[stream.readUint16()]);
                    };

                    Method savedata = new Method();
                    savedata.name = name;
                    savedata.methodUtype = methodUtype;
                    savedata.args = args;

                    module.cell_methods[name] = savedata;
                    module.idcell_methods[methodUtype] = savedata;
                    Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: add(" + scriptmethod_name + "), cell_method(" + name + ").");
                };

                if(module.script == null)
                {
                    Dbg.ERROR_MSG("KBEngine::Client_onImportClientEntityDef: module(" + scriptmethod_name + ") not found!");
                }

                foreach(string name in module.propertys.Keys)
                {
                    Property infos = module.propertys[name];

                    Property newp = new Property();
                    newp.name = infos.name;
                    newp.properUtype = infos.properUtype;
                    newp.utype = infos.utype;
                    newp.val = infos.utype.parseDefaultValStr(infos.defaultValStr);
                    newp.setmethod = infos.setmethod;

                    defpropertys.Add(infos.name, newp);
                    if(module.script != null && module.script.GetMember(name) == null)
                    {
                        Dbg.ERROR_MSG(scriptmethod_name + "(" + module.script + "):: property(" + name + ") no defined!");
                    }
                };

                foreach(string name in module.methods.Keys)
                {
                    Method infos = module.methods[name];

                    if(module.script != null && module.script.GetMethod(name) == null)
                    {
                        Dbg.WARNING_MSG(scriptmethod_name + "(" + module.script + "):: method(" + name + ") no implement!");
                    }
                };
            }

            onImportEntityDefCompleted();
        }
Ejemplo n.º 11
0
        /*
            脚本版本不匹配
        */
        public void Client_onScriptVersionNotMatch(MemoryStream stream)
        {
            serverScriptVersion = stream.readString();

            Dbg.ERROR_MSG("Client_onScriptVersionNotMatch: verInfo=" + clientScriptVersion + "(server: " + serverScriptVersion + ")");
            Event.fireAll("onScriptVersionNotMatch", new object[]{clientScriptVersion, serverScriptVersion});

            if(_persistentInofs != null)
                _persistentInofs.onScriptVersionNotMatch(clientScriptVersion, serverScriptVersion);
        }
Ejemplo n.º 12
0
        /*
            握手之后服务端的回调
        */
        public void Client_onHelloCB(MemoryStream stream)
        {
            serverVersion = stream.readString();
            serverScriptVersion = stream.readString();
            serverProtocolMD5 = stream.readString();
            serverEntitydefMD5 = stream.readString();
            Int32 ctype = stream.readInt32();

            Dbg.DEBUG_MSG("KBEngine::Client_onHelloCB: verInfo(" + serverVersion
                + "), scriptVersion("+ serverScriptVersion + "), srvProtocolMD5("+ serverProtocolMD5
                + "), srvEntitydefMD5("+ serverEntitydefMD5 + "), + ctype(" + ctype + ")!");

            onServerDigest();

            if(currserver == "baseapp")
            {
                onLogin_baseapp();
            }
            else
            {
                onLogin_loginapp();
            }
        }
Ejemplo n.º 13
0
        protected override void onAsyncConnect(ConnectState state)
        {
            try
            {
                //state.socket.Connect(state.connectIP, state.connectPort);

                byte[] helloPacket = System.Text.Encoding.ASCII.GetBytes(UDP_HELLO);
                state.socket.SendTo(helloPacket, helloPacket.Length, SocketFlags.None, new IPEndPoint(IPAddress.Parse(state.connectIP), state.connectPort));

                ArrayList readList = new ArrayList();
                readList.Add(state.socket);
                Socket.Select(readList, null, null, 3000000);

                if (readList.Count > 0)
                {
                    byte[] buffer = new byte[UDP_PACKET_MAX];
                    int    length = state.socket.Receive(buffer);

                    if (length <= 0)
                    {
                        Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), failed to connect to '{0}:{1}'! receive hello-ack error!", state.connectIP, state.connectPort));
                        state.error = "receive hello-ack error!";
                    }
                    else
                    {
                        MemoryStream stream = new MemoryStream();
                        Array.Copy(buffer, 0, stream.data(), stream.wpos, length);
                        stream.wpos = length;
                        string helloAck      = stream.readString();
                        string versionString = stream.readString();
                        uint   conv          = stream.readUint32();

                        if (helloAck != UDP_HELLO_ACK)
                        {
                            Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), failed to connect to '{0}:{1}'! receive hello-ack({2}!={3}) mismatch!",
                                                        state.connectIP, state.connectPort, helloAck, UDP_HELLO_ACK));

                            state.error = "hello-ack mismatch!";
                        }
                        else if (KBEngineApp.app.serverVersion != versionString)
                        {
                            Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), failed to connect to '{0}:{1}'! version({2}!={3}) mismatch!",
                                                        state.connectIP, state.connectPort, versionString, KBEngineApp.app.serverVersion));

                            state.error = "version mismatch!";
                        }
                        else if (conv == 0)
                        {
                            Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), failed to connect to '{0}:{1}'! conv is 0!",
                                                        state.connectIP, state.connectPort));

                            state.error = "kcp conv error!";
                        }

                        ((NetworkInterfaceKCP)state.networkInterface).connID = conv;
                    }
                }
                else
                {
                    Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), connect to '{0}:{1}' timeout!'", state.connectIP, state.connectPort));
                    state.error = "timeout!";
                }
            }
            catch (Exception e)
            {
                Dbg.ERROR_MSG(string.Format("NetworkInterfaceKCP::_asyncConnect(), connect to '{0}:{1}' fault! error = '{2}'", state.connectIP, state.connectPort, e));
                state.error = e.ToString();
            }
        }
Ejemplo n.º 14
0
		public override object createFromStream(MemoryStream stream)
		{
			return stream.readString();
		}
Ejemplo n.º 15
0
        public void Client_initSpaceData(MemoryStream stream)
        {
            spacedatas.Clear();
            UInt32 spaceID = stream.readUint32();
            KBEngineApp.app.spaceID = spaceID;

            while(stream.opsize() > 0)
            {
                string key = stream.readString();
                string val = stream.readString();
                Client_setSpaceData(spaceID, key, val);
            }

            Dbg.DEBUG_MSG("KBEngine::Client_initSpaceData: spaceID(" + spaceID + "), size(" + spacedatas.Count + ")!");
        }
Ejemplo n.º 16
0
        public void onImportClientMessages(MemoryStream stream)
        {
            UInt16 msgcount = stream.readUint16();

            Dbg.DEBUG_MSG(string.Format("KBEngine::Client_onImportClientMessages: start currserver=" + currserver + "(msgsize={0})...", msgcount));

            while(msgcount > 0)
            {
                msgcount--;

                MessageID msgid = stream.readUint16();
                Int16 msglen = stream.readInt16();

                string msgname = stream.readString();
                sbyte argstype = stream.readInt8();
                Byte argsize = stream.readUint8();
                List<Byte> argstypes = new List<Byte>();

                for(Byte i=0; i<argsize; i++)
                {
                    argstypes.Add(stream.readUint8());
                }

                System.Reflection.MethodInfo handler = null;
                bool isClientMethod = msgname.Contains("Client_");

                if(isClientMethod)
                {
                    handler = typeof(KBEngineApp).GetMethod(msgname);
                    if(handler == null)
                    {
                        Dbg.WARNING_MSG(string.Format("KBEngine::onImportClientMessages[{0}]: interface({1}/{2}/{3}) no implement!",
                            currserver, msgname, msgid, msglen));

                        handler = null;
                    }
                    else
                    {
                        //Dbg.DEBUG_MSG(string.Format("KBEngine::onImportClientMessages: imported({0}/{1}/{2}) successfully!",
                        //	msgname, msgid, msglen));
                    }
                }

                if(msgname.Length > 0)
                {
                    Message.messages[msgname] = new Message(msgid, msgname, msglen, argstype, argstypes, handler);

                    //if(!isClientMethod)
                    //	Dbg.DEBUG_MSG(string.Format("KBEngine::onImportClientMessages[{0}]: imported({1}/{2}/{3}) successfully!",
                    //		currserver, msgname, msgid, msglen));

                    if(isClientMethod)
                    {
                        Message.clientMessages[msgid] = Message.messages[msgname];
                    }
                    else
                    {
                        if(currserver == "loginapp")
                            Message.loginappMessages[msgid] = Message.messages[msgname];
                        else
                            Message.baseappMessages[msgid] = Message.messages[msgname];
                    }
                }
                else
                {
                    Message msg = new Message(msgid, msgname, msglen, argstype, argstypes, handler);

                    //if(!isClientMethod)
                    //	Dbg.DEBUG_MSG(string.Format("KBEngine::onImportClientMessages[{0}]: imported({1}/{2}/{3}) successfully!",
                    //		currserver, msgname, msgid, msglen));

                    if(currserver == "loginapp")
                        Message.loginappMessages[msgid] = msg;
                    else
                        Message.baseappMessages[msgid] = msg;
                }
            };

            onImportClientMessagesCompleted();
        }
Ejemplo n.º 17
0
        /*
            服务端初始化客户端的spacedata, spacedata请参考API
        */
        public void Client_initSpaceData(MemoryStream stream)
        {
            clearSpace(false);
            spaceID = stream.readUint32();

            while(stream.length() > 0)
            {
                string key = stream.readString();
                string val = stream.readString();
                Client_setSpaceData(spaceID, key, val);
            }

            Dbg.DEBUG_MSG("KBEngine::Client_initSpaceData: spaceID(" + spaceID + "), size(" + _spacedatas.Count + ")!");
        }
Ejemplo n.º 18
0
        public void Client_onVersionNotMatch(MemoryStream stream)
        {
            serverVersion_ = stream.readString();
            Dbg.DEBUG_MSG("Client_onVersionNotMatch: verInfo=" + clientVersion_ + " not match(server: " + serverVersion_ + ")");

            Event.fire("onVersionNotMatch", new object[]{clientVersion_, serverVersion_});
        }
Ejemplo n.º 19
0
        /*
            登录loginapp成功了
        */
        public void Client_onLoginSuccessfully(MemoryStream stream)
        {
            var accountName = stream.readString();
            username = accountName;
            baseappIP = stream.readString();
            baseappPort = stream.readUint16();

            Dbg.DEBUG_MSG("KBEngine::Client_onLoginSuccessfully: accountName(" + accountName + "), addr(" +
                    baseappIP + ":" + baseappPort + "), datas(" + _serverdatas.Length + ")!");

            _serverdatas = stream.readBlob();
            login_baseapp(true);
        }
Ejemplo n.º 20
0
        public void createDataTypeFromStream(MemoryStream stream, bool canprint)
        {
            UInt16 utype = stream.readUint16();
            string name = stream.readString();
            string valname = stream.readString();

            if(canprint)
                Dbg.DEBUG_MSG("KBEngine::Client_onImportClientEntityDef: importAlias(" + name + ":" + valname + ")!");

            if(valname == "FIXED_DICT")
            {
                KBEDATATYPE_FIXED_DICT datatype = new KBEDATATYPE_FIXED_DICT();
                Byte keysize = stream.readUint8();
                datatype.implementedBy = stream.readString();

                while(keysize > 0)
                {
                    keysize--;

                    string keyname = stream.readString();
                    UInt16 keyutype = stream.readUint16();
                    datatype.dicttype[keyname] = keyutype;
                };

                EntityDef.datatypes[name] = datatype;
            }
            else if(valname == "ARRAY")
            {
                UInt16 uitemtype = stream.readUint16();
                KBEDATATYPE_ARRAY datatype = new KBEDATATYPE_ARRAY();
                datatype.type = uitemtype;
                EntityDef.datatypes[name] = datatype;
            }
            else
            {
                KBEDATATYPE_BASE val = null;
                EntityDef.datatypes.TryGetValue(valname, out val);
                EntityDef.datatypes[name] = val;
            }

            EntityDef.iddatatypes[utype] = EntityDef.datatypes[name];
            EntityDef.datatype2id[name] = EntityDef.datatype2id[valname];
        }
Ejemplo n.º 21
0
 public override object createFromStream(MemoryStream stream)
 {
     return(stream.readString());
 }
Ejemplo n.º 22
0
 public void Client_onHelloCB(MemoryStream stream)
 {
     serverVersion_ = stream.readString();
     Int32 ctype = stream.readInt32();
     Dbg.DEBUG_MSG("KBEngine::Client_onHelloCB: verInfo(" + serverVersion_ + "), ctype(" + ctype + ")!");
 }