Skip to content

Commit 22da23b

Browse files
committed
identifier 生成は JSON シリアライズ成功後にする
1 parent 41c707c commit 22da23b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Sora/RPC.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,6 @@ public final class RPCChannel {
124124
}
125125
}
126126

127-
var identifier: RPCID?
128-
if !isNotificationRequest {
129-
let nextIdentifier = nextIdentifier()
130-
identifier = nextIdentifier
131-
payload["id"] = nextIdentifier.jsonValue
132-
}
133-
134127
guard JSONSerialization.isValidJSONObject(payload) else {
135128
completion?(.failure(SoraError.rpcEncodingError(reason: "invalid JSON payload")))
136129
return false
@@ -144,6 +137,13 @@ public final class RPCChannel {
144137
return false
145138
}
146139

140+
var identifier: RPCID?
141+
if !isNotificationRequest {
142+
let nextIdentifier = nextIdentifier()
143+
identifier = nextIdentifier
144+
payload["id"] = nextIdentifier.jsonValue
145+
}
146+
147147
var pending: Pending?
148148
if !isNotificationRequest, let identifier {
149149
// タイムアウト時に実行されるタスク

0 commit comments

Comments
 (0)