Skip to content

Commit

Permalink
easier migration
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin committed Nov 13, 2023
1 parent afa00a7 commit 3e599b9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public final class com/apollographql/apollo3/network/websocket/GraphQLWsProtocol
}

public final class com/apollographql/apollo3/network/websocket/JvmWebSocketEngine : com/apollographql/apollo3/network/websocket/WebSocketEngine {
public fun <init> (Lokhttp3/OkHttpClient$Builder;)V
public fun <init> (Lokhttp3/OkHttpClient;)V
public fun newWebSocket (Ljava/lang/String;Ljava/util/List;Lcom/apollographql/apollo3/network/websocket/WebSocketListener;)Lcom/apollographql/apollo3/network/websocket/WebSocket;
}

Expand Down Expand Up @@ -108,7 +108,7 @@ public abstract interface class com/apollographql/apollo3/network/websocket/Serv
}

public final class com/apollographql/apollo3/network/websocket/SubscriptionWsProtocol : com/apollographql/apollo3/network/websocket/WsProtocol {
public fun <init> (Lkotlin/jvm/functions/Function1;)V
public synthetic fun <init> (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun connectionInit (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun getConnectionParams ()Lkotlin/jvm/functions/Function1;
public fun getName ()Ljava/lang/String;
Expand All @@ -121,8 +121,13 @@ public final class com/apollographql/apollo3/network/websocket/SubscriptionWsPro

public final class com/apollographql/apollo3/network/websocket/SubscriptionWsProtocol$Factory : com/apollographql/apollo3/network/websocket/WsProtocol$Factory {
public fun <init> ()V
public fun <init> (J)V
public fun <init> (JLkotlin/jvm/functions/Function1;)V
public fun <init> (JLkotlin/jvm/functions/Function1;Lcom/apollographql/apollo3/network/ws/WsFrameType;)V
public synthetic fun <init> (JLkotlin/jvm/functions/Function1;Lcom/apollographql/apollo3/network/ws/WsFrameType;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Lkotlin/jvm/functions/Function1;)V
public synthetic fun <init> (Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun build ()Lcom/apollographql/apollo3/network/websocket/WsProtocol;
public final fun connectionParams (Lkotlin/jvm/functions/Function1;)Lcom/apollographql/apollo3/network/websocket/SubscriptionWsProtocol$Factory;
}

public final class com/apollographql/apollo3/network/websocket/TextClientMessage : com/apollographql/apollo3/network/websocket/ClientMessage {
Expand Down Expand Up @@ -173,11 +178,12 @@ public final class com/apollographql/apollo3/network/websocket/WebSocketNetworkT
public final fun headers (Ljava/util/List;)Lcom/apollographql/apollo3/network/websocket/WebSocketNetworkTransport$Builder;
public final fun idleTimeoutMillis (J)Lcom/apollographql/apollo3/network/websocket/WebSocketNetworkTransport$Builder;
public final fun pingIntervalMillis (J)Lcom/apollographql/apollo3/network/websocket/WebSocketNetworkTransport$Builder;
public final fun protocol (Lcom/apollographql/apollo3/network/websocket/WsProtocol$Factory;)Lcom/apollographql/apollo3/network/websocket/WebSocketNetworkTransport$Builder;
public final fun reopenWhen (Lkotlin/jvm/functions/Function3;)Lcom/apollographql/apollo3/network/websocket/WebSocketNetworkTransport$Builder;
public final fun serverUrl (Ljava/lang/String;)Lcom/apollographql/apollo3/network/websocket/WebSocketNetworkTransport$Builder;
public final fun serverUrl (Lkotlin/jvm/functions/Function1;)Lcom/apollographql/apollo3/network/websocket/WebSocketNetworkTransport$Builder;
public final fun webSocketEngine (Lcom/apollographql/apollo3/network/websocket/WebSocketEngine;)Lcom/apollographql/apollo3/network/websocket/WebSocketNetworkTransport$Builder;
public final fun wsProtocolBuilder (Lcom/apollographql/apollo3/network/websocket/WsProtocol$Factory;)Lcom/apollographql/apollo3/network/websocket/WebSocketNetworkTransport$Builder;
public final fun wsProtocolFactory (Lcom/apollographql/apollo3/network/websocket/WsProtocol$Factory;)Lcom/apollographql/apollo3/network/websocket/WebSocketNetworkTransport$Builder;
}

public abstract interface class com/apollographql/apollo3/network/websocket/WebSocketNetworkTransport$Event {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.apollographql.apollo3.network.websocket

import com.apollographql.apollo3.annotations.ApolloDeprecatedSince
import com.apollographql.apollo3.api.ApolloRequest
import com.apollographql.apollo3.api.Operation
import com.apollographql.apollo3.api.http.DefaultHttpRequestComposer
import com.apollographql.apollo3.api.json.jsonReader
import com.apollographql.apollo3.api.json.readAny
import com.apollographql.apollo3.network.ws.WsFrameType
import okio.Buffer
import kotlin.jvm.JvmOverloads

class SubscriptionWsProtocol(
class SubscriptionWsProtocol private constructor(
val connectionParams: suspend () -> Any?,
) : WsProtocol {
override val name: String
Expand Down Expand Up @@ -81,14 +84,28 @@ class SubscriptionWsProtocol(
}
}

class Factory : WsProtocol.Factory {
private var connectionParams: (suspend () -> Any?)? = null
fun connectionParams(connectionParams: suspend () -> Any?) = apply {
this.connectionParams = connectionParams
}
class Factory
@Deprecated("Use WsProtocol.Factory(connectionPayload) instead")
@ApolloDeprecatedSince(ApolloDeprecatedSince.Version.v4_0_0)
@JvmOverloads constructor(
private val connectionAcknowledgeTimeoutMs: Long = 10_000,
private var connectionPayload: suspend () -> Any? = { null },
private val frameType: WsFrameType = WsFrameType.Text,
) : WsProtocol.Factory {

@Suppress("DEPRECATION")
constructor(connectionPayload: suspend () -> Any? = { null }): this(connectionAcknowledgeTimeoutMs = 10_000, connectionPayload = connectionPayload)

override fun build(): WsProtocol {
return SubscriptionWsProtocol(connectionParams ?: { null })
check(frameType == WsFrameType.Text) {
"Binary websocket frames are not supported"
}
check(connectionAcknowledgeTimeoutMs == 10_000L) {
"Changing connectionAcknowledgeTimeoutMs on WsProtocol is deprecated, use WebSocketNetworkTransport.connectionAcknowledgeTimeoutMillis instead"
}
return SubscriptionWsProtocol(
connectionPayload
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ class WebSocketNetworkTransport private constructor(
this.wsProtocolFactory = wsProtocolFactory
}

@Deprecated("Use wsProtocolFactory isntead", ReplaceWith("wsProtocolFactory"), level = DeprecationLevel.ERROR)
@Deprecated("Use wsProtocolFactory instead", ReplaceWith("wsProtocolFactory"), level = DeprecationLevel.ERROR)
@ApolloDeprecatedSince(ApolloDeprecatedSince.Version.v4_0_0)
fun protocol(wsProtocolFactory: WsProtocol.Factory) = wsProtocolFactory(wsProtocolFactory)

/**
Expand Down

0 comments on commit 3e599b9

Please sign in to comment.