MCPcopy Create free account
hub / github.com/actix/examples / new

Method new

websockets/chat-actorless/src/server.rs:67–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65
66impl ChatServer {
67 pub fn new() -> (Self, ChatServerHandle) {
68 // create empty server
69 let mut rooms = HashMap::with_capacity(4);
70
71 // create default room
72 rooms.insert("main".to_owned(), HashSet::new());
73
74 let (cmd_tx, cmd_rx) = mpsc::unbounded_channel();
75
76 (
77 Self {
78 sessions: HashMap::new(),
79 rooms,
80 visitor_count: Arc::new(AtomicUsize::new(0)),
81 cmd_rx,
82 },
83 ChatServerHandle { cmd_tx },
84 )
85 }
86
87 /// Send message to users in a room.
88 ///

Callers

nothing calls this directly

Calls 1

insertMethod · 0.80

Tested by

no test coverage detected