/// <summary> /// /// </summary> /// <param name="strIP"></param> /// <param name="nPort"></param> /// <param name="callback"></param> /// <param name="receiveCallback"></param> /// <param name="disconnectCallback"></param> /// <param name="owner">lua table </param> public void Connect(string strIP, int nPort, Engine.ConnectCallback callback, Engine.ReceiveMsgCallback receiveCallback, Engine.DisconnectCallback disconnectCallback, object owner = null) { if (netLink == null || netLinkSink == null) { Log.Error("NetService:netLink or netLinkSink is null"); return; } netLinkSink.connectCallback = callback; netLinkSink.DisconnectCallback = disconnectCallback; netLinkSink.ReceiveMsgCallback = receiveCallback; netLinkSink.CallbackOwner = owner; netLinkSink.netState = NetLinkSink.NetState.NetState_Login; netLink.Connect(strIP, nPort); }
static int _m_Connect(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Engine.NetService __cl_gen_to_be_invoked = (Engine.NetService)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if (__gen_param_count == 7 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && translator.Assignable <Engine.ConnectCallback>(L, 4) && translator.Assignable <Engine.ReceiveMsgCallback>(L, 5) && translator.Assignable <Engine.DisconnectCallback>(L, 6) && translator.Assignable <object>(L, 7)) { string strIP = LuaAPI.lua_tostring(L, 2); int nPort = LuaAPI.xlua_tointeger(L, 3); Engine.ConnectCallback callback = translator.GetDelegate <Engine.ConnectCallback>(L, 4); Engine.ReceiveMsgCallback receiveCallback = translator.GetDelegate <Engine.ReceiveMsgCallback>(L, 5); Engine.DisconnectCallback disconnectCallback = translator.GetDelegate <Engine.DisconnectCallback>(L, 6); object owner = translator.GetObject(L, 7, typeof(object)); __cl_gen_to_be_invoked.Connect(strIP, nPort, callback, receiveCallback, disconnectCallback, owner); return(0); } if (__gen_param_count == 6 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && translator.Assignable <Engine.ConnectCallback>(L, 4) && translator.Assignable <Engine.ReceiveMsgCallback>(L, 5) && translator.Assignable <Engine.DisconnectCallback>(L, 6)) { string strIP = LuaAPI.lua_tostring(L, 2); int nPort = LuaAPI.xlua_tointeger(L, 3); Engine.ConnectCallback callback = translator.GetDelegate <Engine.ConnectCallback>(L, 4); Engine.ReceiveMsgCallback receiveCallback = translator.GetDelegate <Engine.ReceiveMsgCallback>(L, 5); Engine.DisconnectCallback disconnectCallback = translator.GetDelegate <Engine.DisconnectCallback>(L, 6); __cl_gen_to_be_invoked.Connect(strIP, nPort, callback, receiveCallback, disconnectCallback); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to Engine.NetService.Connect!")); }