@@ -160,11 +160,6 @@ void EmmyFacade::Destroy() {
160160void EmmyFacade::OnReceiveMessage (const rapidjson::Document& document) {
161161 const auto cmd = static_cast <MessageCMD>(document[" cmd" ].GetInt ());
162162 switch (cmd) {
163- #if EMMY_BUILD_AS_HOOK
164- case MessageCMD::StartHookReq:
165- StartHook ();
166- break ;
167- #endif
168163 case MessageCMD::InitReq:
169164 OnInitReq (document);
170165 break ;
@@ -191,24 +186,28 @@ void EmmyFacade::OnReceiveMessage(const rapidjson::Document& document) {
191186}
192187
193188void EmmyFacade::OnInitReq (const rapidjson::Document& document) {
189+ #if EMMY_BUILD_AS_HOOK
190+ StartHook ();
191+ #endif
194192 if (document.HasMember (" emmyHelper" )) {
195193 helperCode = document[" emmyHelper" ].GetString ();
196- // Debugger::Get()->AsyncDoString(helperCode.c_str());
197194 }
198195 Debugger::Get ()->Start (helperCode);
199196 for (auto L : states)
200197 Debugger::Get ()->Attach (L);
198+
199+ // file extension names: .lua, .txt, .lua.txt ...
200+ std::vector<std::string> extNames;
201201 if (document.HasMember (" ext" )) {
202- std::vector<std::string> extNames;
203202 const auto ext = document[" ext" ].GetArray ();
204203 auto it = ext.begin ();
205204 while (it != ext.end ()) {
206205 const auto extName = (*it).GetString ();
207206 extNames.emplace_back (extName);
208207 ++it;
209208 }
210- Debugger::Get ()->SetExtNames (extNames);
211209 }
210+ Debugger::Get ()->SetExtNames (extNames);
212211}
213212
214213void EmmyFacade::OnReadyReq (const rapidjson::Document& document) {
@@ -398,11 +397,8 @@ void EmmyFacade::OnLuaStateGC(lua_State* L) {
398397 if (it != states.end ())
399398 states.erase (it);
400399 Debugger::Get ()->Detach (L);
401- if (!states.empty ())
402- return ;
403- #if EMMY_BUILD_AS_HOOK
404- OnDisconnect ();
405- #else
406- Destroy ();
400+ #if !EMMY_BUILD_AS_HOOK
401+ if (states.empty ())
402+ Destroy ();
407403#endif
408404}
0 commit comments