@@ -158,6 +158,11 @@ YASIO_LUA_API int luaopen_yasio(lua_State* L)
158158# else
159159 auto yasio_lib = state_view.create_named_table (" yasio" );
160160# endif
161+ yasio_lib.new_usertype <ip::endpoint>(
162+ " endpoint" , " ip" , [](const ip::endpoint& ep) { return ep.ip (); }, " port" , [](const ip::endpoint& ep) { return ep.port (); });
163+ yasio_lib.new_usertype <io_transport>(
164+ " io_transport" , " remote_endpoint" , [](io_transport* transport) { return transport->remote_endpoint (); }, " local_endpoint" ,
165+ [](io_transport* transport) { return transport->local_endpoint (); });
161166 yasio_lib.new_usertype <io_event>(
162167 " io_event" , " kind" , &io_event::kind, " status" , &io_event::status, " passive" , [](io_event* e) { return !!e->passive (); }, " packet" ,
163168 [](io_event* ev, sol::variadic_args args, sol::this_state s) {
@@ -172,9 +177,9 @@ YASIO_LUA_API int luaopen_yasio(lua_State* L)
172177 case lyasio::BUFFER_RAW:
173178 return sol::make_object (L, cxx17::string_view{packet_data (pkt), packet_len (pkt)});
174179 case lyasio::BUFFER_FAST:
175- return sol::make_object (L, cxx14::make_unique<yasio::fast_ibstream>(forward_packet ((packet_t &&) pkt)));
180+ return sol::make_object (L, cxx14::make_unique<yasio::fast_ibstream>(forward_packet ((packet_t &&)pkt)));
176181 default :
177- return sol::make_object (L, cxx14::make_unique<yasio::ibstream>(forward_packet ((packet_t &&) pkt)));
182+ return sol::make_object (L, cxx14::make_unique<yasio::ibstream>(forward_packet ((packet_t &&)pkt)));
178183 }
179184 },
180185 " cindex" , &io_event::cindex, " transport" , &io_event::transport
@@ -596,7 +601,7 @@ YASIO_LUA_API int luaopen_yasio(lua_State* L)
596601 auto & pkt = ev->packet ();
597602 if (is_packet_empty (pkt))
598603 return std::unique_ptr<yasio::ibstream>{};
599- return cxx14::make_unique<yasio::ibstream>(forward_packet ((packet_t &&) pkt));
604+ return cxx14::make_unique<yasio::ibstream>(forward_packet ((packet_t &&)pkt));
600605 })
601606 .addStaticFunction (" raw_packet" ,
602607 [](io_event* ev) {
@@ -610,15 +615,15 @@ YASIO_LUA_API int luaopen_yasio(lua_State* L)
610615 auto & pkt = ev->packet ();
611616 if (is_packet_empty (pkt))
612617 return std::unique_ptr<yasio::fast_ibstream>{};
613- return cxx14::make_unique<yasio::fast_ibstream>(forward_packet ((packet_t &&) pkt));
618+ return cxx14::make_unique<yasio::fast_ibstream>(forward_packet ((packet_t &&)pkt));
614619 })
615620 .addFunction (" cindex" , &io_event::cindex)
616621 .addFunction (" transport" , &io_event::transport)
617622 .addFunction (" timestamp" , &io_event::timestamp));
618623# if !YASIO_LUA_ENABLE_GLOBAL
619624 state[" yasio" ] = yasio_lib;
620625# endif
621- bool succeed = state.dostring (R"(
626+ bool succeed = state.dostring (R"(
622627local yasio = yasio;
623628yasio.io_event.packet = function(self, buffer_type)
624629 if buffer_type == yasio.BUFFER_RAW then
0 commit comments