rsocket / rsocket-java

Java implementation of RSocket
http://rsocket.io
Apache License 2.0
2.35k stars 354 forks source link

Ability to store session object inside RSocketRequester chain #1068

Open maxim-bandurko-lsvt opened 2 years ago

maxim-bandurko-lsvt commented 2 years ago

Hello.

Would be very nice to add to somewhere inside RSocketRequester the AtomicReference<Object> type field that will cache the session object for reuse, especially it will be very convenient to obtain value from it inside MessageMappings at Spring Boot.

I am coming from this: #831 and had implemented a basic wrapper around WebsocketDuplexConnection as to cache this value. Not a big deal, it is just needed to use reflection per each ws route as to get that session object, but would be nice, if that it can have native public method not so chained to obtain it.

Thank you.

maxim-bandurko-lsvt commented 2 years ago

Forgot to add, it is Object type because it can be anything that may be needed. For example, Long, instance or even Mono Publisher that will supply the needed instance from session storage. I think that it will be very useful, as it will allow finally to have sessions insider RSocket and more on that, sessions can use Spring Security part and have same sessions to both RSocket and Spring Boot.