Huge refactor to prep for moving the daemon over to the plugin architecture
parent: tbd commit: 5df753c
1 | use Arc; |
2 | |
3 | use ; |
4 | use |
5 | , |
6 | , | Instance
7 | , | ObjectBackend
8 | ; |
9 | use Runtime; |
10 | use ; |
11 | use TcpStream; |
12 | use ; |
13 | |
14 | pub async |
15 | our_instance: Instance, |
16 | mut socket: , |
17 | runtime: , |
18 | |
19 | loop |
20 | let message = socket.next .await; |
21 | |
22 | if message.is_none |
23 | // Keep an eye out for this, I dont see why we shouldn't end the connection |
24 | unreachable! |
25 | |
26 | |
27 | let message = message.unwrap; |
28 | |
29 | let payload = match message |
30 | Ok => |
31 | let payload = match message |
32 | => payload, | Binary
33 | => | Ping
34 | let _ = socket.send .await; |
35 | continue; |
36 | |
37 | => return, | Close
38 | _ => continue, |
39 | ; |
40 | |
41 | payload |
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: StackOperationState, |
98 | runtime: , |
99 | |
100 | // let mut networked_object = runtime |
101 | // .get_object::<NetworkedObject>(&payload.object, &operation_state) |
102 | // .await |
103 | // .as_internal_error_with_context("handling client message")?; |
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(networked_operation, &operation_state) |
117 | // .await |
118 | |
119 | todo! |
120 | |
121 |