@@ -9,6 +9,9 @@ import kotlinx.coroutines.suspendCancellableCoroutine
99import kotlin.coroutines.resume
1010import kotlin.coroutines.resumeWithException
1111
12+ /* *
13+ * Spec: RTO15g
14+ */
1215internal suspend fun LiveObjectsAdapter.sendAsync (message : ProtocolMessage ) = suspendCancellableCoroutine { continuation ->
1316 try {
1417 this .send(message, object : CompletionListener {
@@ -25,11 +28,14 @@ internal suspend fun LiveObjectsAdapter.sendAsync(message: ProtocolMessage) = su
2528 }
2629}
2730
31+ /* *
32+ * Spec: RTO15d
33+ */
2834internal fun LiveObjectsAdapter.ensureMessageSizeWithinLimit (objectMessages : Array <ObjectMessage >) {
2935 val maximumAllowedSize = maxMessageSizeLimit()
3036 val objectsTotalMessageSize = objectMessages.sumOf { it.size() }
3137 if (objectsTotalMessageSize > maximumAllowedSize) {
32- throw ablyException(" ObjectMessage size $objectsTotalMessageSize exceeds maximum allowed size of $maximumAllowedSize bytes" ,
38+ throw ablyException(" ObjectMessages size $objectsTotalMessageSize exceeds maximum allowed size of $maximumAllowedSize bytes" ,
3339 ErrorCode .MaxMessageSizeExceeded )
3440 }
3541}
@@ -53,6 +59,13 @@ internal fun LiveObjectsAdapter.throwIfInvalidWriteApiConfiguration(channelName:
5359 throwIfInChannelState(channelName, arrayOf(ChannelState .detached, ChannelState .failed, ChannelState .suspended))
5460}
5561
62+ internal fun LiveObjectsAdapter.throwIfUnpublishableState (channelName : String ) {
63+ if (! connectionManager.isActive) {
64+ throw ablyException(connectionManager.stateErrorInfo)
65+ }
66+ throwIfInChannelState(channelName, arrayOf(ChannelState .failed, ChannelState .suspended))
67+ }
68+
5669// Spec: RTO2
5770internal fun LiveObjectsAdapter.throwIfMissingChannelMode (channelName : String , channelMode : ChannelMode ) {
5871 val channelModes = getChannelModes(channelName)
0 commit comments