Git repository hosting, collaboration, and discovery for the Fediverse.
Fixes schmixes
parent: tbd commit: 92ff417
1 | use SinkExt; |
2 | |
3 | use Serialize; |
4 | use Message; |
5 | |
6 | use crate Socket; |
7 | |
8 | ; |
9 | |
10 | |
11 | |
12 | Self |
13 | |
14 | |
15 | pub async |
16 | // let mut socket = self.0; |
17 | |
18 | // // Send handshake initiation |
19 | // Self::send_raw_message( |
20 | // &mut socket, |
21 | // &InitiateHandshake { |
22 | // version: Version::from_str("0.0.0").unwrap(), |
23 | // }, |
24 | // ) |
25 | // .await?; |
26 | |
27 | // while let Some(message) = socket.next().await { |
28 | // let message = match message { |
29 | // Ok(message) => message, |
30 | // Err(err) => { |
31 | // error!("Error reading message: {:?}", err); |
32 | // continue; |
33 | // } |
34 | // }; |
35 | |
36 | // let payload = match message { |
37 | // Message::Text(text) => text.into_bytes(), |
38 | // Message::Binary(bytes) => bytes, |
39 | // Message::Ping(_) => continue, |
40 | // Message::Pong(_) => continue, |
41 | // Message::Close(_) => { |
42 | // socket.close(None).await?; |
43 | |
44 | // return Err(SocketClosedError.into()); |
45 | // } |
46 | // _ => unreachable!(), |
47 | // }; |
48 | |
49 | // info!("Read payload: {}", std::str::from_utf8(&payload).unwrap()); |
50 | |
51 | // // We try deserializing the finalize response first as it is smaller and just as common |
52 | // if let Ok(finalize) = serde_json::from_slice::<HandshakeFinalize>(&payload) { |
53 | // if finalize.success { |
54 | // info!("Handshake success!"); |
55 | |
56 | // return Ok(socket); |
57 | // } else { |
58 | // socket.close(None).await?; |
59 | // return Err(SocketClosedError.into()); |
60 | // } |
61 | // } else { |
62 | // match serde_json::from_slice::<HandshakeResponse>(&payload) { |
63 | // Ok(_response) => { |
64 | // // let message = if !validate_version(&response.version) { |
65 | // // error!( |
66 | // // "Version compatibility failure! Our Version: {}, Their Version: {}", |
67 | // // version(), |
68 | // // response.version |
69 | // // ); |
70 | |
71 | // // HandshakeFinalize { success: false } |
72 | // // } else { |
73 | // // info!("Connected with a compatible version"); |
74 | |
75 | // // HandshakeFinalize { success: true } |
76 | // // }; |
77 | |
78 | // warn!("Version compatibility has been no-op'd"); |
79 | |
80 | // let message = HandshakeFinalize { success: true }; |
81 | // // Send [`HandshakeFinalize`] to indicate if we're compatible or not |
82 | // Self::send_raw_message(&mut socket, &message).await?; |
83 | // } |
84 | // Err(err) => { |
85 | // error!("Error deserializing message: {:?}", err); |
86 | // continue; |
87 | // } |
88 | // } |
89 | // } |
90 | // } |
91 | |
92 | Ok |
93 | |
94 | |
95 | async |
96 | socket: &mut Socket, |
97 | message: &T, |
98 | |
99 | socket |
100 | .send |
101 | .await?; |
102 | |
103 | Ok |
104 | |
105 | |
106 | |
107 | |
108 | |
109 | ; |
110 |