INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: What happens when MJ closes?  (Read 2168 times)

apranger

  • Regular Member
  • Member
  • *
  • Posts: 4
What happens when MJ closes?
« on: July 06, 2002, 08:32:04 am »

What happens when MJ closes, or exits, etc?

Do MJ plugins recieve any sort of event or message that can be handled?  Web Remote keeps some socket connections open (in ziggraut's modified version), and we have to close them before MJ goes away to prevent a crash on exit.

Adam
Logged

Nikolay

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1681
  • Former CTO, JRiver, Inc.
RE:What happens when MJ closes?
« Reply #1 on: July 08, 2002, 11:30:34 am »

Plug-in can do clean up two ways:
1. implement OnFinalRelease function, I think it works only in MFC.
2. implement Terminate function (void Terminate(void)), the function implementation is similar to Init function.

Nikolay
Logged

zigguratt

  • Regular Member
  • World Citizen
  • ***
  • Posts: 114
RE:What happens when MJ closes?
« Reply #2 on: July 08, 2002, 12:02:52 pm »

On a quick first attempt the function doesn't seem to be called.

I added

void CWebRemoteCtrl::Terminate(void)
{
   m_HTTPServer.StopServer();
}

just after the definition of Init() in WebRemoteCtrl.cpp and added "void Terminate(void);" in the .h file just after the Init line as well. To prove it wasn't called, I put an infinite loop in Terminate() so I could see everything freeze. It didn't.
Logged
The latest version of Glissando can be had here.

Nikolay

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1681
  • Former CTO, JRiver, Inc.
RE:What happens when MJ closes?
« Reply #3 on: July 08, 2002, 01:00:26 pm »

I fogot to mention, but Terminate function must be implemented as COM function. For that you need to modify 3 files:

WebRemote.idl:
interface IWebRemoteCtrl : IDispatch
{
 [id(1), helpstring("method Init")] HRESULT Init([in] LPDISPATCH pDisp);
[id(2), helpstring("method Terminate")] HRESULT Terminate(); };

WebRemoteCtrl.cpp:

STDMETHODIMP CWebRemoteCtrl::Terminate()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())

...

return S_OK;
}

WebRemoteCtrl.cpp:
STDMETHOD(Terminate)();

Nikolay
Logged

zigguratt

  • Regular Member
  • World Citizen
  • ***
  • Posts: 114
RE:What happens when MJ closes?
« Reply #4 on: July 08, 2002, 04:26:04 pm »

Thanks Nikolay, I've added the code as you specified above and all compiles properly. Now I just have to figure out how to keep track of the sockets that are open and close them all on termination.
Logged
The latest version of Glissando can be had here.
Pages: [1]   Go Up