space928 / Omsi-Extensions

Omsi hooking and modding sdk
GNU Lesser General Public License v3.0
17 stars 3 forks source link

RPC does not discard clients that no longer exist #97

Closed BlueOrange775 closed 2 months ago

BlueOrange775 commented 6 months ago

Describe the bug Clients are not 'disconnected' from OmsiHookRPCPlugin when shut down outside of the game, meaning that after 8 shutdowns (during debugging for example), the plugin will not attach to OmsiHook since the connection limit is 8.

I hope my explanation makes sense. If you need any more information let me know.

To Reproduce

space928 commented 6 months ago

This is somewhat of a design limitation with my current implementation. The issue is that the communication protocol being used, Windows Named Pipes, doesn't automatically notify the server when a client disconnects, so it's up to the client to let the server know when it disconnects. I do provide a method which you can call to close your current RPC session (or close all "active" RPC sessions): CloseRPCSession https://space928.github.io/Omsi-Extensions/api/OmsiHook.OmsiRemoteMethods.CloseRPCSession.html#OmsiHook_OmsiRemoteMethods_CloseRPCSession_System_Boolean_. For now, as long as you remember to call CloseRPCSession when the application exits it should solve the issue.

A better solution would probably be to make the OmsiRemoteMethods class non-static and make it implement IDisposable such that it can close the RPC session itself when it's disposed of. An instance of OmsiRemoteMethods would then be made accessible from the OmsiHook instance, which would also need to be made disposable. These would all be breaking API changes, but it's probably the neatest solution in the long run.

On Sun, 5 May 2024 at 00:57, BlueOrange775 @.***> wrote:

Describe the bug Clients are not 'disconnected' from OmsiHookRPCPlugin when shut down outside of the game, meaning that after 8 shutdowns (during debugging for example), the plugin will not attach to OmsiHook since the connection limit is 8.

I hope my explanation makes sense. If you need any more information let me know.

To Reproduce

  • Create basic OMSIHook plugin, running independent of the game
  • Close and restart the plugin several times
  • after 8 times it will refuse to connect and throw System.AggregateException

— Reply to this email directly, view it on GitHub https://github.com/space928/Omsi-Extensions/issues/97, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADTN4AUVRZEWRI3V2URQLWTZAVYXRAVCNFSM6AAAAABHHGVPHWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI3TSMRUGIZDGMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Thomas