Spinning
parent: tbd commit: 1788060
1 | use ; |
2 | |
3 | use Error; |
4 | use ; |
5 | use |
6 | , |
7 | , | Instance
8 | , | GiteratedObject
9 | , | GiteratedOperation
10 | ; |
11 | use ; |
12 | use ; |
13 | use TcpStream; |
14 | use ; |
15 | |
16 | use crate::; |
17 | |
18 | pub async |
19 | _state: ProtocolState, |
20 | object: NetworkedObject, |
21 | operation: NetworkedOperation, |
22 | runtime: RuntimeHandle, |
23 | |
24 | trace!; |
25 | |
26 | runtime |
27 | .handle_serialized |
28 | .await |
29 | |
30 | |
31 | |
32 | ; |
33 | |
34 | |
35 | type Err = ; |
36 | |
37 | |
38 | Ok |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | f.write_str |
45 | |
46 | |
47 | |
48 | |
49 | |
50 | "networked_object" |
51 | |
52 | |
53 | |
54 | todo! |
55 | |
56 | |
57 | |
58 | todo! |
59 | |
60 | |
61 | |
62 | |
63 | |
64 | pub name: String, |
65 | pub payload: , |
66 | |
67 | |
68 | |
69 | |
70 | Self |
71 | |
72 | |
73 | |
74 | |
75 | type Success = ; |
76 | |
77 | type Failure = ; |
78 | |
79 | |
80 | "networked_operation" |
81 | |
82 | |
83 | |
84 | /// Handler which will attempt to resolve any operation that doesn't resolve locally |
85 | /// against a remote instance. |
86 | pub async |
87 | state: ProtocolState, |
88 | object: Object, |
89 | operation: Operation, |
90 | _runtime: RuntimeHandle, |
91 | |
92 | // if object.is::<NetworkedObject>() { |
93 | // return Err(OperationError::Unhandled); |
94 | // } |
95 | // trace!( |
96 | // "Try handling object operation {}::{} with remote", |
97 | // object.kind(), |
98 | // operation.kind().operation_name |
99 | // ); |
100 | // TODO: |
101 | // Ideally we support pass-through on object types that aren't used locally. |
102 | // For now, we aren't worrying about that. |
103 | // let object_meta = object.vtable(); |
104 | |
105 | let operation_meta = operation.vtable; |
106 | |
107 | // trace!( |
108 | // "Serializing with {}::{}", |
109 | // operation.kind().object_name, |
110 | // operation.kind().operation_name |
111 | // ); |
112 | |
113 | let object_home_uri = object.home_uri; |
114 | |
115 | if let Some = state.home_uri |
116 | if home_uri == object_home_uri |
117 | // This isn't a remote request, requests aren't supposed to hit this layer |
118 | // if they're not remote. |
119 | // warn!("Try handling object operation {}::{}, resolved object home uri as local home uri. This is a bug.", object.kind(), |
120 | // operation.kind().operation_name); |
121 | |
122 | return Err; |
123 | |
124 | |
125 | |
126 | // trace!( |
127 | // "Handling object operation {}::{} sending payload", |
128 | // object.kind(), |
129 | // operation.kind().operation_name |
130 | // ); |
131 | |
132 | // let object = NetworkedObject(unsafe { (object_meta.to_str)(object).as_ref().to_string() }); |
133 | |
134 | let object = todo!; |
135 | |
136 | let payload = operation.serialize; |
137 | |
138 | let operation = new; |
139 | |
140 | // let authenticated = Authenticated::new(object, operation); |
141 | |
142 | let message = GiteratedMessage |
143 | object, |
144 | operation: operation_name .to_string, |
145 | payload: operation, |
146 | ; |
147 | |
148 | let authenticated = new; |
149 | |
150 | let mut socket: = connect_to |
151 | & from_str .unwrap, |
152 | &Some, |
153 | |
154 | .await |
155 | .unwrap; |
156 | |
157 | // TODO AUTH |
158 | |
159 | let result: = |
160 | send_expect .await; |
161 | |
162 | match result |
163 | Ok => |
164 | let success = unsafe |
165 | .map_err?; |
166 | |
167 | Ok |
168 | |
169 | Err => Err |
170 | => | Operation
171 | let failure = unsafe |
172 | .map_err?; |
173 | |
174 | Operation |
175 | |
176 | => Internal, | Internal
177 | => Unhandled, | Unhandled
178 | , |
179 | |
180 | |
181 | |
182 | type Socket = ; |
183 | |
184 | async |
185 | instance: &Instance, |
186 | |
187 | socket_addr: & , |
188 | |
189 | if let Some = socket_addr |
190 | info! |
191 | "Connecting to {}", |
192 | format! |
193 | ; |
194 | |
195 | let = |
196 | connect_async .await?; |
197 | |
198 | info!; |
199 | |
200 | Ok |
201 | else |
202 | info! |
203 | "Connecting to {}", |
204 | format! |
205 | ; |
206 | |
207 | let = |
208 | connect_async .await?; |
209 | |
210 | info!; |
211 | |
212 | Ok |
213 | |
214 | |
215 | |
216 | async |
217 | socket: &mut Socket, |
218 | message: , |
219 | |
220 | let payload = serialize .unwrap; |
221 | |
222 | socket.send .await.unwrap; |
223 | |
224 | while let Some = socket.next .await |
225 | let payload = match message.unwrap |
226 | => payload, | Binary
227 | |
228 | _ => |
229 | continue; |
230 | |
231 | ; |
232 | |
233 | let raw_result = |
234 | |
235 | .map_err?; |
236 | |
237 | trace! |
238 | "Received response for networked operation {}::{}.", |
239 | , | object_name
240 | operation_name |
241 | ; |
242 | |
243 | return match raw_result |
244 | Ok => Ok, |
245 | Err => Err |
246 | => | Operation
247 | Operation |
248 | |
249 | => Internal, | Internal
250 | => Unhandled, | Unhandled
251 | , |
252 | ; |
253 | |
254 | |
255 | panic! |
256 | |
257 |