{"action":"created","issue":{"url":"https://api.github.com/repos/esa/CCSDS_MO_TRANS/issues/8","repository_url":"https://api.github.com/repos/esa/CCSDS_MO_TRANS","labels_url":"https://api.github.com/repos/esa/CCSDS_MO_TRANS/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/esa/CCSDS_MO_TRANS/issues/8/comments","events_url":"https://api.github.com/repos/esa/CCSDS_MO_TRANS/issues/8/events","html_url":"https://github.com/esa/CCSDS_MO_TRANS/issues/8","id":180005633,"number":8,"title":"How to use two decoder/encoder per message?","user":{"login":"gbonnefille","id":14096450,"avatar_url":"https://avatars.githubusercontent.com/u/14096450?v=3","gravatar_id":"","url":"https://api.github.com/users/gbonnefille","html_url":"https://github.com/gbonnefille","followers_url":"https://api.github.com/users/gbonnefille/followers","following_url":"https://api.github.com/users/gbonnefille/following{/other_user}","gists_url":"https://api.github.com/users/gbonnefille/gists{/gist_id}","starred_url":"https://api.github.com/users/gbonnefille/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbonnefille/subscriptions","organizations_url":"https://api.github.com/users/gbonnefille/orgs","repos_url":"https://api.github.com/users/gbonnefille/repos","events_url":"https://api.github.com/users/gbonnefille/events{/privacy}","received_events_url":"https://api.github.com/users/gbonnefille/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-29T10:02:41Z","updated_at":"2016-10-03T08:19:11Z","closed_at":"2016-10-03T08:19:11Z","body":"In order to implement TCP/IP transport as drafted in [Mission Operations - Message Abstraction Layer Binding to TCP/IP Transport and Split Binary Encoding Draft Recommended Standard](http://public.ccsds.org/sites/cwe/rids/Lists/CCSDS%205242R1/Attachments/524x2r1.pdf), we have to use two distinct decoders per message:\r\n* `FixedBinaryDecoder` for the header ;\r\n* `SplitBinaryDecoder` for the body.\r\n\r\nOne part of the solution seems to be the creation of a dedicated `StreamFactory` in order to control the decoding/encoding logic. The code seems quite ready for that because many constructors allow specific feature for sub-classes. But there is an underlaying problem: the implementation of these decoder/encoder are not able to share a single `InputStream`. The reason is both use an internal buffer. So, the first decoder read as many bytes as possible, do is job and when the second try to do is job, it reclaims bytes from the `InputStream`, but it is empty.\r\n\r\nIs there any recommended approach to do this?\r\n\r\nIn our side, we imagine that the logic of the buffered input should be extracted from encoder/decoder and ported by the InputStream directly. By this way, we will be able to share the same buffered input between `FixedBinaryDecoder` and `SplitBinaryDecoder`."},"comment":{"url":"https://api.github.com/repos/esa/CCSDS_MO_TRANS/issues/comments/251050616","html_url":"https://github.com/esa/CCSDS_MO_TRANS/issues/8#issuecomment-251050616","issue_url":"https://api.github.com/repos/esa/CCSDS_MO_TRANS/issues/8","id":251050616,"user":{"login":"SamCooper","id":3294590,"avatar_url":"https://avatars.githubusercontent.com/u/3294590?v=3","gravatar_id":"","url":"https://api.github.com/users/SamCooper","html_url":"https://github.com/SamCooper","followers_url":"https://api.github.com/users/SamCooper/followers","following_url":"https://api.github.com/users/SamCooper/following{/other_user}","gists_url":"https://api.github.com/users/SamCooper/gists{/gist_id}","starred_url":"https://api.github.com/users/SamCooper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamCooper/subscriptions","organizations_url":"https://api.github.com/users/SamCooper/orgs","repos_url":"https://api.github.com/users/SamCooper/repos","events_url":"https://api.github.com/users/SamCooper/events{/privacy}","received_events_url":"https://api.github.com/users/SamCooper/received_events","type":"User","site_admin":false},"created_at":"2016-10-03T08:19:11Z","updated_at":"2016-10-03T08:19:11Z","body":"The SPP encoding need to also do this, take a look here to see how it does it:\r\n\r\nhttps://github.com/esa/CCSDS_MO_TRANS/blob/master/CCSDS_MAL_TRANSPORT_SPP/src/main/java/esa/mo/mal/transport/spp/SPPMessageHeader.java#L274\r\n\r\nIt may not be perfect in which case you may need to make modifications but if you do this I should be able to bring those changes back into the main tree as long as they are done in a portable way."}}
{"actor":{"display_login":"SamCooper"}}