206 lines
6.2 KiB
C#
206 lines
6.2 KiB
C#
#if USE_UNI_LUA
|
|
using LuaAPI = UniLua.Lua;
|
|
using RealStatePtr = UniLua.ILuaState;
|
|
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
|
|
#else
|
|
using LuaAPI = XLua.LuaDLL.Lua;
|
|
using RealStatePtr = System.IntPtr;
|
|
using LuaCSFunction = XLuaBase.lua_CSFunction;
|
|
#endif
|
|
|
|
using XLua;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace XLua.CSObjectWrap
|
|
{
|
|
using Utils = XLua.Utils;
|
|
public class XGamelsocketWrap
|
|
{
|
|
public static void __Register(RealStatePtr L)
|
|
{
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
System.Type type = typeof(XGame.lsocket);
|
|
Utils.BeginObjectRegister(type, L, translator, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
Utils.RegisterFunc(L, Utils.GETTER_IDX, "Instance", _g_get_Instance);
|
|
|
|
Utils.RegisterFunc(L, Utils.SETTER_IDX, "Instance", _s_set_Instance);
|
|
|
|
|
|
Utils.EndObjectRegister(type, L, translator, null, null,
|
|
null, null, null);
|
|
|
|
Utils.BeginClassRegister(type, L, __CreateInstance, 4, 0, 0);
|
|
Utils.RegisterFunc(L, Utils.CLS_IDX, "gettime", _m_gettime_xlua_st_);
|
|
Utils.RegisterFunc(L, Utils.CLS_IDX, "connect", _m_connect_xlua_st_);
|
|
Utils.RegisterFunc(L, Utils.CLS_IDX, "select", _m_select_xlua_st_);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Utils.EndClassRegister(type, L, translator);
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int __CreateInstance(RealStatePtr L)
|
|
{
|
|
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
if(LuaAPI.lua_gettop(L) == 1)
|
|
{
|
|
|
|
var gen_ret = new XGame.lsocket();
|
|
translator.Push(L, gen_ret);
|
|
|
|
return 1;
|
|
}
|
|
|
|
}
|
|
catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return LuaAPI.luaL_error(L, "invalid arguments to XGame.lsocket constructor!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_gettime_xlua_st_(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
var gen_ret = XGame.lsocket.gettime( );
|
|
LuaAPI.lua_pushnumber(L, gen_ret);
|
|
|
|
|
|
|
|
return 1;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_connect_xlua_st_(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
|
|
|
|
{
|
|
string _addr = LuaAPI.lua_tostring(L, 1);
|
|
int _port = LuaAPI.xlua_tointeger(L, 2);
|
|
System.Action<XGame.XWebSocket, string> _callback = translator.GetDelegate<System.Action<XGame.XWebSocket, string>>(L, 3);
|
|
|
|
XGame.lsocket.connect( _addr, _port, _callback );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_select_xlua_st_(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
|
|
|
|
{
|
|
XGame.XWebSocket[] _readSockets = (XGame.XWebSocket[])translator.GetObject(L, 1, typeof(XGame.XWebSocket[]));
|
|
XGame.XWebSocket[] _writeSockets = (XGame.XWebSocket[])translator.GetObject(L, 2, typeof(XGame.XWebSocket[]));
|
|
int _Param = LuaAPI.xlua_tointeger(L, 3);
|
|
XGame.XWebSocket[] _retWriteSockets = (XGame.XWebSocket[])translator.GetObject(L, 4, typeof(XGame.XWebSocket[]));
|
|
int _dataSize = LuaAPI.xlua_tointeger(L, 5);
|
|
|
|
var gen_ret = XGame.lsocket.select( _readSockets, _writeSockets, _Param, ref _retWriteSockets, ref _dataSize );
|
|
translator.Push(L, gen_ret);
|
|
translator.Push(L, _retWriteSockets);
|
|
|
|
LuaAPI.xlua_pushinteger(L, _dataSize);
|
|
|
|
|
|
|
|
|
|
return 3;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _g_get_Instance(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
XGame.lsocket gen_to_be_invoked = (XGame.lsocket)translator.FastGetCSObj(L, 1);
|
|
translator.Push(L, gen_to_be_invoked.Instance);
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _s_set_Instance(RealStatePtr L)
|
|
{
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
XGame.lsocket gen_to_be_invoked = (XGame.lsocket)translator.FastGetCSObj(L, 1);
|
|
gen_to_be_invoked.Instance = (XGame.lsocket)translator.GetObject(L, 2, typeof(XGame.lsocket));
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|