Created
April 28, 2020 10:42
-
-
Save Malinskiy/2a531188d07347fbfb3755173e4731b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This type of request starts with single serialized request | |
* and then proceed to do several reads and writes that have dynamic size | |
*/ | |
abstract class ComplexRequest<T : Any?>(target: Target = NonSpecifiedTarget) : Request(target) { | |
/** | |
* Some requests ignore the initial OKAY/FAIL response and instead stream the actual response | |
* To implement these we allow overriding this method | |
*/ | |
open suspend fun process(readChannel: AndroidReadChannel, writeChannel: AndroidWriteChannel): T { | |
handshake(readChannel, writeChannel) | |
return readElement(readChannel, writeChannel) | |
} | |
abstract suspend fun readElement(readChannel: AndroidReadChannel, writeChannel: AndroidWriteChannel): T | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment