MCPcopy Create free account
hub / github.com/Wulf/create-rust-app / handle_socket

Function handle_socket

crates/create-rust-app/src/dev/dev_server.rs:129–331  ·  view source on GitHub ↗
(stream: WebSocket, state: Arc<AppState>)

Source from the content-addressed store, hash-verified

127/// TODO break this function up into smaller sub functions
128#[allow(clippy::too_many_lines)]
129async fn handle_socket(stream: WebSocket, state: Arc<AppState>) {
130 use axum::extract::ws::Message;
131 let (mut sender, mut receiver) = stream.split();
132
133 /*
134 SECTION: sending initial state
135 */
136 let compiler_messages = state.dev.lock().unwrap().compiler_messages.clone();
137 let backend_status = state.dev.lock().unwrap().backend_status;
138 let backend_compiling = state.dev.lock().unwrap().backend_compiling;
139 let backend_restarting = state.dev.lock().unwrap().backend_restarting;
140 let backend_compiled = state.dev.lock().unwrap().backend_compiled;
141 let vite_status = state.dev.lock().unwrap().vite_status;
142 let features = state.dev.lock().unwrap().features.clone();
143 let migrations_pending = state.dev.lock().unwrap().migrations_pending.clone();
144 sender
145 .send(Message::Text(DevServerEvent::FeaturesList(features).json()))
146 .await
147 .unwrap();
148 sender
149 .send(Message::Text(
150 DevServerEvent::CompileSuccess(backend_compiled).json(),
151 ))
152 .await
153 .unwrap();
154 sender
155 .send(Message::Text(
156 DevServerEvent::CompileMessages(compiler_messages).json(),
157 ))
158 .await
159 .unwrap();
160 sender
161 .send(Message::Text(
162 DevServerEvent::BackendStatus(backend_status).json(),
163 ))
164 .await
165 .unwrap();
166 sender
167 .send(Message::Text(
168 DevServerEvent::BackendRestarting(backend_restarting).json(),
169 ))
170 .await
171 .unwrap();
172 sender
173 .send(Message::Text(
174 DevServerEvent::BackendCompiling(backend_compiling).json(),
175 ))
176 .await
177 .unwrap();
178 sender
179 .send(Message::Text(
180 DevServerEvent::ViteJSStatus(vite_status).json(),
181 ))
182 .await
183 .unwrap();
184 sender
185 .send(Message::Text(
186 DevServerEvent::PendingMigrations(migrations_pending.0, migrations_pending.1).json(),

Callers 1

ws_handlerFunction · 0.85

Calls 6

get_migrationsFunction · 0.85
needs_migrationFunction · 0.85
migrate_dbFunction · 0.85
sendMethod · 0.80
jsonMethod · 0.80
to_stringMethod · 0.80

Tested by

no test coverage detected