{"action":"opened","issue":{"url":"https://api.github.com/repos/tavendo/AutobahnCpp/issues/54","labels_url":"https://api.github.com/repos/tavendo/AutobahnCpp/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/tavendo/AutobahnCpp/issues/54/comments","events_url":"https://api.github.com/repos/tavendo/AutobahnCpp/issues/54/events","html_url":"https://github.com/tavendo/AutobahnCpp/issues/54","id":106800987,"number":54,"title":"Implement an abstraction for input streams and output streams","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},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-16T15:41:46Z","updated_at":"2015-09-16T15:41:46Z","closed_at":null,"body":"The session API is templated and requires that both an input stream and output stream be provided. or example:\r\n\r\n    autobahn::session<boost::asio::local::stream_protocol::socket, boost::asio::local::stream_protocol::socket>\r\n    autobahn::session<boost::asio::ip::tcp::socket, boost::asio::ip::tcp::socket>\r\n    autobahn::session<int, int>\r\n\r\nCalls to *boost::asio::write*, *boost::asio::read*, and *boost::asio::async_read* are then issued internally as required to send and receive messages. This is restricting such that the templated types must be compatible with *boost::asio* semantics for reading and writing data. In the near future, support will likely be added for Websocket, HTTP/2, and a native in application transport to call directly into a WAMP router. In order to do this, we will need to be able to have the session API internally write to these types of transports. As a result we need to provide further abstraction in place of the templated streams that are provided to the session. For example:\r\n\r\n    class wamp_stream\r\n    {\r\n    public:\r\n        wamp_stream();\r\n        virtual wamp_stream();\r\n\r\n        virtual int read(char* buffer, int length) = 0;\r\n        virtual void async_read(char* buffer, int length, read_handler handler) = 0;\r\n        virtual void write(const char* buffer, int length) = 0;\r\n    };\r\n \r\n    class wamp_websocket_stream : public wamp_stream\r\n    {\r\n    ...\r\n    };\r\n\r\n    class wamp_http2_stream : public wamp_stream\r\n    {\r\n    ...\r\n    };\r\n\r\n    class wamp_native_stream : public wamp_stream\r\n    {\r\n    ...\r\n    };\r\n\r\nThen we can change the session API to no longer require templates for the input and output streams and instead pass in objects of the desired types:\r\n\r\n    autobahn::session(boost::asio::io_service& io, wamp_stream& in, wamp_stream& out, bool debug=false)\r\n"}}