{"action":"created","issue":{"url":"https://api.github.com/repos/tplgy/bonefish/issues/31","labels_url":"https://api.github.com/repos/tplgy/bonefish/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/tplgy/bonefish/issues/31/comments","events_url":"https://api.github.com/repos/tplgy/bonefish/issues/31/events","html_url":"https://github.com/tplgy/bonefish/issues/31","id":125484559,"number":31,"title":"Dynamic Realm Support","user":{"login":"pramukta","id":61136,"avatar_url":"https://avatars.githubusercontent.com/u/61136?v=3","gravatar_id":"","url":"https://api.github.com/users/pramukta","html_url":"https://github.com/pramukta","followers_url":"https://api.github.com/users/pramukta/followers","following_url":"https://api.github.com/users/pramukta/following{/other_user}","gists_url":"https://api.github.com/users/pramukta/gists{/gist_id}","starred_url":"https://api.github.com/users/pramukta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pramukta/subscriptions","organizations_url":"https://api.github.com/users/pramukta/orgs","repos_url":"https://api.github.com/users/pramukta/repos","events_url":"https://api.github.com/users/pramukta/events{/privacy}","received_events_url":"https://api.github.com/users/pramukta/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-01-07T21:06:28Z","updated_at":"2016-01-08T13:49:14Z","closed_at":null,"body":"This is a great looking project.  It's really great to see a nice minimalist WAMP router as a static library.  I am somewhat in the same boat as @estan who opened #9 but also could really use automatically managed realms as well.  So by that I mean that a realm would be created when a client tried to join it and would be thrown out when the last client left it.  I think this would be really convenient for people doing WAMP development as well.  What would you guys think about incorporating something like that into the codebase?  \r\n\r\nMy C++ is rusty almost to the point of being non-existent but I did manage to put together a **[proof of concept branch](https://github.com/pramukta/bonefish/tree/dynamic-realms)**.  It definitely would require someone more knowledgeable to go over but the general approach I tried was:\r\n\r\n1.  Allow `src/bonefish/router/wamp_routers` to track an `io_service` reference and use it to create and add routers/realms in `get_realm`\r\n2.  Expose a `has_sessions()` method on the `src/bonefish/router/wamp_router`\r\n3.  Have the `on_close` and `on_fail` handlers from `websocket_server` remove the realm if `has_sessions()` returns false.\r\n\r\nI modified `examples/integration.cpp` to run this \"dynamic\" mode.  The standard `bonefish` binary works exactly as before.  I don't think this is PR worthy yet but wanted to see what folks thought.  And definitely point out anything i'm thinking about wrong.  Thanks."},"comment":{"url":"https://api.github.com/repos/tplgy/bonefish/issues/comments/170008185","html_url":"https://github.com/tplgy/bonefish/issues/31#issuecomment-170008185","issue_url":"https://api.github.com/repos/tplgy/bonefish/issues/31","id":170008185,"user":{"login":"davidchappelle","id":2732639,"avatar_url":"https://avatars.githubusercontent.com/u/2732639?v=3","gravatar_id":"","url":"https://api.github.com/users/davidchappelle","html_url":"https://github.com/davidchappelle","followers_url":"https://api.github.com/users/davidchappelle/followers","following_url":"https://api.github.com/users/davidchappelle/following{/other_user}","gists_url":"https://api.github.com/users/davidchappelle/gists{/gist_id}","starred_url":"https://api.github.com/users/davidchappelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidchappelle/subscriptions","organizations_url":"https://api.github.com/users/davidchappelle/orgs","repos_url":"https://api.github.com/users/davidchappelle/repos","events_url":"https://api.github.com/users/davidchappelle/events{/privacy}","received_events_url":"https://api.github.com/users/davidchappelle/received_events","type":"User","site_admin":false},"created_at":"2016-01-08T13:49:14Z","updated_at":"2016-01-08T13:49:14Z","body":"I am not sure that dynamic realms are something that we want to support at the present time. A realm is something that is usually statically provisioned/defined so that it can be administered and even potentially utilized by multiple routers. When you define a realm you define other characteristics associated with that realm. For example, the roles supported.\r\n\r\nFurthermore, when you define a router, you need to also define the realm(s) that it is associated with. You also need to define a number of other characteristics regarding transports, authentication, etc. Some of these configuration parameters are not yet in place but will be added in the future. There are of course other concerns here as well like DOS attacks that can occur by allowing arbitrary hosts to dynamically allocate routers/realms.\r\n\r\nI think that if we were to support dynamic realms we would need the following items in place first:\r\n\r\n1. A proper configuration mechanism for the bonefish daemon as discussed in #13.\r\n2. A proper administration interface that can be used to authenticate a client and allow it to perform configuration. This would allow clients to dynamically allocate routers/realms.\r\n\r\nIn the meantime, a better suited workaround for what you are trying to achieve would be to simply spin up new instances of bonefish. This would allow you the ability to set the realm/port of each bonefish instance and give you the dynamic behaviour that you are looking for. Since the clients would need to know which realm to connect to you must be preserving/passing that information anyways. So adding the port along with the realm name shouldn't pose a problem. "}}