How do I serialize `DefaultWebSocketServerSession`...
# ktor
How do I serialize
What’s your use case? What are you trying to achieve?
store it in redis
But that session is a wrapped socket connection, that won’t exists later. You cannot serialize a socket
what you can do is to serialize a state that you associate to that session
you can use jackson or gson to serialize/deserialize a simple data class with your state, but not with a socket
If I have ktor on multiple instances, how do I share websocket sessions?
usually you have a session, you can store it on redis if you want
Here there is a proposal for redis sessions: You can copy the code and use the redis client you are using for it
As long as the client has the same session-id, if it reconnects to another server, that redis-backed session should work
if you want the state to be associated to the user instead to a session
you can use raw redis to do that
for example:
hset("props-$userId", "property", "value")