mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Fix web sockets using old registry values
This commit is contained in:
parent
ebdc8a6261
commit
616846c316
1 changed files with 14 additions and 16 deletions
|
@ -89,20 +89,19 @@ where
|
||||||
type NetWebSocketStreamClient = MaybeTlsStream<TcpStream>;
|
type NetWebSocketStreamClient = MaybeTlsStream<TcpStream>;
|
||||||
impl NetWebSocket<NetWebSocketStreamClient> {
|
impl NetWebSocket<NetWebSocketStreamClient> {
|
||||||
pub fn into_lua_table(self, lua: &'static Lua) -> LuaResult<LuaTable> {
|
pub fn into_lua_table(self, lua: &'static Lua) -> LuaResult<LuaTable> {
|
||||||
|
let setmetatable = lua.globals().get::<_, LuaFunction>("setmetatable")?;
|
||||||
|
let table_freeze = lua
|
||||||
|
.globals()
|
||||||
|
.get::<_, LuaTable>("table")?
|
||||||
|
.get::<_, LuaFunction>("freeze")?;
|
||||||
let socket_env = TableBuilder::new(lua)?
|
let socket_env = TableBuilder::new(lua)?
|
||||||
.with_value("websocket", self)?
|
.with_value("websocket", self)?
|
||||||
.with_function("close_code", close_code::<NetWebSocketStreamClient>)?
|
.with_function("close_code", close_code::<NetWebSocketStreamClient>)?
|
||||||
.with_async_function("close", close::<NetWebSocketStreamClient>)?
|
.with_async_function("close", close::<NetWebSocketStreamClient>)?
|
||||||
.with_async_function("send", send::<NetWebSocketStreamClient>)?
|
.with_async_function("send", send::<NetWebSocketStreamClient>)?
|
||||||
.with_async_function("next", next::<NetWebSocketStreamClient>)?
|
.with_async_function("next", next::<NetWebSocketStreamClient>)?
|
||||||
.with_value(
|
.with_value("setmetatable", setmetatable)?
|
||||||
"setmetatable",
|
.with_value("freeze", table_freeze)?
|
||||||
lua.named_registry_value::<LuaFunction>("tab.setmeta")?,
|
|
||||||
)?
|
|
||||||
.with_value(
|
|
||||||
"freeze",
|
|
||||||
lua.named_registry_value::<LuaFunction>("tab.freeze")?,
|
|
||||||
)?
|
|
||||||
.build_readonly()?;
|
.build_readonly()?;
|
||||||
Self::into_lua_table_with_env(lua, socket_env)
|
Self::into_lua_table_with_env(lua, socket_env)
|
||||||
}
|
}
|
||||||
|
@ -111,20 +110,19 @@ impl NetWebSocket<NetWebSocketStreamClient> {
|
||||||
type NetWebSocketStreamServer = Upgraded;
|
type NetWebSocketStreamServer = Upgraded;
|
||||||
impl NetWebSocket<NetWebSocketStreamServer> {
|
impl NetWebSocket<NetWebSocketStreamServer> {
|
||||||
pub fn into_lua_table(self, lua: &'static Lua) -> LuaResult<LuaTable> {
|
pub fn into_lua_table(self, lua: &'static Lua) -> LuaResult<LuaTable> {
|
||||||
|
let setmetatable = lua.globals().get::<_, LuaFunction>("setmetatable")?;
|
||||||
|
let table_freeze = lua
|
||||||
|
.globals()
|
||||||
|
.get::<_, LuaTable>("table")?
|
||||||
|
.get::<_, LuaFunction>("freeze")?;
|
||||||
let socket_env = TableBuilder::new(lua)?
|
let socket_env = TableBuilder::new(lua)?
|
||||||
.with_value("websocket", self)?
|
.with_value("websocket", self)?
|
||||||
.with_function("close_code", close_code::<NetWebSocketStreamServer>)?
|
.with_function("close_code", close_code::<NetWebSocketStreamServer>)?
|
||||||
.with_async_function("close", close::<NetWebSocketStreamServer>)?
|
.with_async_function("close", close::<NetWebSocketStreamServer>)?
|
||||||
.with_async_function("send", send::<NetWebSocketStreamServer>)?
|
.with_async_function("send", send::<NetWebSocketStreamServer>)?
|
||||||
.with_async_function("next", next::<NetWebSocketStreamServer>)?
|
.with_async_function("next", next::<NetWebSocketStreamServer>)?
|
||||||
.with_value(
|
.with_value("setmetatable", setmetatable)?
|
||||||
"setmetatable",
|
.with_value("freeze", table_freeze)?
|
||||||
lua.named_registry_value::<LuaFunction>("tab.setmeta")?,
|
|
||||||
)?
|
|
||||||
.with_value(
|
|
||||||
"freeze",
|
|
||||||
lua.named_registry_value::<LuaFunction>("tab.freeze")?,
|
|
||||||
)?
|
|
||||||
.build_readonly()?;
|
.build_readonly()?;
|
||||||
Self::into_lua_table_with_env(lua, socket_env)
|
Self::into_lua_table_with_env(lua, socket_env)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue