Connection
parent: tbd commit: 415ff8d
1 | use ; |
2 | |
3 | use ; |
4 | use Listeners; |
5 | use |
6 | , |
7 | , |
8 | , | Mutex
9 | ; |
10 | use ; |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | extern crate tracing; |
20 | |
21 | |
22 | async |
23 | let mut listener = bind .await?; |
24 | let mut connections: = default; |
25 | let mut listeners: = default; |
26 | |
27 | loop |
28 | let stream = accept_stream .await; |
29 | |
30 | let = match stream |
31 | Ok => stream, |
32 | Err => |
33 | error!; |
34 | continue; |
35 | |
36 | ; |
37 | |
38 | let connection = accept_websocket_connection .await; |
39 | |
40 | let connection = match connection |
41 | Ok => connection, |
42 | Err => |
43 | error! |
44 | "Failed to initiate Websocket connection from {}. {:?}", |
45 | address, err |
46 | ; |
47 | continue; |
48 | |
49 | ; |
50 | |
51 | let connection = RawConnection |
52 | task: spawn |
53 | connection, |
54 | listeners.clone, |
55 | connections.clone, |
56 | address, |
57 | , |
58 | ; |
59 | |
60 | connections.lock .await.connections.push; |
61 | |
62 | |
63 | |
64 | async |
65 | listener: &mut TcpListener, |
66 | |
67 | let stream = listener.accept .await?; |
68 | |
69 | Ok |
70 | |
71 | |
72 | async |
73 | stream: S, |
74 | |
75 | let connection = accept_async .await?; |
76 | |
77 | Ok |
78 | |
79 |