More progress :)
parent: tbd commit: 92c3f32
1 | use Arc; |
2 | |
3 | use ; |
4 | use |
5 | , |
6 | , | Instance
7 | , | ObjectBackend
8 | , | OperationState
9 | ; |
10 | use ; |
11 | use |
12 | , |
13 | AuthenticatedPayload, |
14 | ; |
15 | use TcpStream; |
16 | use ; |
17 | |
18 | pub async |
19 | _our_instance: Instance, |
20 | mut socket: , |
21 | _runtime: , |
22 | |
23 | loop |
24 | let message = socket.next .await; |
25 | |
26 | if message.is_none |
27 | // Keep an eye out for this, I dont see why we shouldn't end the connection |
28 | unreachable! |
29 | |
30 | |
31 | let message = message.unwrap; |
32 | |
33 | let payload = match message |
34 | Ok => match message |
35 | => payload, | Binary
36 | => | Ping
37 | let _ = socket.send .await; |
38 | continue; |
39 | |
40 | => return, | Close
41 | _ => continue, |
42 | , |
43 | Err => |
44 | // Connection error |
45 | warn!; |
46 | |
47 | return; |
48 | |
49 | ; |
50 | |
51 | trace!; |
52 | |
53 | let payload = match |
54 | Ok => payload, |
55 | Err => |
56 | warn! |
57 | "A network payload deserialization failure has occurred: {:?}", |
58 | e |
59 | ; |
60 | |
61 | continue; |
62 | |
63 | ; |
64 | |
65 | trace! |
66 | "Deserialized payload for operation {} from client", |
67 | payload.operation |
68 | ; |
69 | |
70 | todo! |
71 | |
72 | // let operation_state = StackOperationState { |
73 | // our_instance: our_instance.clone(), |
74 | // instance: None, |
75 | // user: None, |
76 | // }; |
77 | |
78 | // let result = handle_client_message(payload, operation_state, runtime.clone()).await; |
79 | |
80 | // Grab operation errors so we can log them, they don't make it across the network |
81 | // if let Err(OperationError::Internal(internal_error)) = &result { |
82 | // error!("An internal error has occurred:\n{:?}", internal_error); |
83 | // } |
84 | |
85 | // // Map error to the network variant |
86 | // let result = result.map_err(|e| e.into_network()); |
87 | |
88 | // socket |
89 | // .send(Message::Binary(bincode::serialize(&result).unwrap())) |
90 | // .await |
91 | // .expect("there was an error sending a message, this is a problem for the receiver"); |
92 | |
93 | |
94 | |
95 | pub async |
96 | payload: AuthenticatedPayload, |
97 | operation_state: OperationState, |
98 | runtime: RuntimeHandle, |
99 | |
100 | let mut networked_object = runtime |
101 | . |
102 | .await |
103 | .as_internal_error_with_context?; |
104 | |
105 | let message: GiteratedMessage = |
106 | payload.into_message; |
107 | |
108 | let networked_operation = new |
109 | message.payload.name.clone, |
110 | message.payload.payload.clone, |
111 | ; |
112 | |
113 | trace!; |
114 | |
115 | networked_object |
116 | .request |
117 | .await |
118 | |
119 |