Add a generic Ack message, use it instead of Pong
Remove the `id` field from `Ping`, because it isn't used. There is already an id on the message envelope.
This commit is contained in:
+6
-12
@@ -371,18 +371,18 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
client1
|
||||
.request(client1_conn_id, proto::Ping { id: 1 },)
|
||||
.request(client1_conn_id, proto::Ping {},)
|
||||
.await
|
||||
.unwrap(),
|
||||
proto::Pong { id: 1 }
|
||||
proto::Ack {}
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
client2
|
||||
.request(client2_conn_id, proto::Ping { id: 2 },)
|
||||
.request(client2_conn_id, proto::Ping {},)
|
||||
.await
|
||||
.unwrap(),
|
||||
proto::Pong { id: 2 }
|
||||
proto::Ack {}
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
@@ -438,13 +438,7 @@ mod tests {
|
||||
let envelope = envelope.into_any();
|
||||
if let Some(envelope) = envelope.downcast_ref::<TypedEnvelope<proto::Ping>>() {
|
||||
let receipt = envelope.receipt();
|
||||
peer.respond(
|
||||
receipt,
|
||||
proto::Pong {
|
||||
id: envelope.payload.id,
|
||||
},
|
||||
)
|
||||
.await?
|
||||
peer.respond(receipt, proto::Ack {}).await?
|
||||
} else if let Some(envelope) =
|
||||
envelope.downcast_ref::<TypedEnvelope<proto::OpenBuffer>>()
|
||||
{
|
||||
@@ -536,7 +530,7 @@ mod tests {
|
||||
smol::spawn(async move { incoming.next().await }).detach();
|
||||
|
||||
let err = client
|
||||
.request(connection_id, proto::Ping { id: 42 })
|
||||
.request(connection_id, proto::Ping {})
|
||||
.await
|
||||
.unwrap_err();
|
||||
assert_eq!(err.to_string(), "connection was closed");
|
||||
|
||||
+2
-2
@@ -120,6 +120,7 @@ macro_rules! entity_messages {
|
||||
}
|
||||
|
||||
messages!(
|
||||
Ack,
|
||||
AddPeer,
|
||||
BufferSaved,
|
||||
ChannelMessageSent,
|
||||
@@ -140,7 +141,6 @@ messages!(
|
||||
OpenWorktree,
|
||||
OpenWorktreeResponse,
|
||||
Ping,
|
||||
Pong,
|
||||
RemovePeer,
|
||||
SaveBuffer,
|
||||
SendChannelMessage,
|
||||
@@ -157,7 +157,7 @@ request_messages!(
|
||||
(JoinChannel, JoinChannelResponse),
|
||||
(OpenBuffer, OpenBufferResponse),
|
||||
(OpenWorktree, OpenWorktreeResponse),
|
||||
(Ping, Pong),
|
||||
(Ping, Ack),
|
||||
(SaveBuffer, BufferSaved),
|
||||
(ShareWorktree, ShareWorktreeResponse),
|
||||
(SendChannelMessage, SendChannelMessageResponse),
|
||||
|
||||
Reference in New Issue
Block a user