fn create_instance(&mut self, conn_id: NetConnId, buf_size: usize, net_sender: &NetSender, components: &[ComponentInfo]) {
        // create an instance to handle the connection, the ChatInstance has two instruction sets.
        // Wire them both to the same instance.
        // Normally, you'd build a translation to a conn_uuid.
        let conn_uuid: u128 = conn_id.try_into().unwrap();
        if self.inst_chat_sender.is_none() {
            // get the instance running
            let (instance, sender) = executor::connect::<_, ChatCmd>(ChatInstance::new(
                conn_uuid,
                std::mem::take(&mut self.kv),
                buf_size,
                net_sender.clone(),
            ));
            // save the chat sender in the coordinator
            self.inst_chat_sender.replace(sender.clone());
            // save the chat sender in the instance
            instance.my_sender.lock().replace(sender);
            // create a net sender for the instance
            let sender = executor::and_connect::<_, NetCmd>(&instance);
            // save the sender in the instance
            self.inst_net_sender.replace(sender);
        }
        // tell the network that the coordinator will handle the connection traffic
        let sender = self.inst_net_sender.as_ref().unwrap().clone();
        send_cmd(net_sender, NetCmd::BindConn(conn_id, sender));
        // let all of the components know that there's a new session for the chat service and how to contact the coordinator
        let sender = self.inst_chat_sender.as_ref().unwrap().clone();
        components.iter().for_each(|c| {
            send_cmd(
                c.sender(),
                ComponentCmd::NewSession(conn_uuid, "ChatService".to_string(), Arc::new(sender.clone())),
            )
        });
    }
// create a coordinator it it hasn't already been created. Then ask the compoents to create
// instances, which the coordinator will assemble.
create a coordinator it it hasn't already been created. Then ask the compoents to create
instances, which the coordinator will assemble.
create a coordinator it it hasn ' t already been created . Then ask the compoents to create instances which the coordinator will assemble .
fn create_instance(&mut self, conn_id: NetConnId, buf_size: usize, net_sender: &NetSender, components: &[ComponentInfo]) {
        // create an instance to handle the connection, the ChatInstance has two instruction sets.
        // Wire them both to the same instance.
        // Normally, you'd build a translation to a conn_uuid.
        let conn_uuid: u128 = conn_id.try_into().unwrap();
        if self.inst_chat_sender.is_none() {
            // get the instance running
            let (instance, sender) = executor::connect::<_, ChatCmd>(ChatInstance::new(
                conn_uuid,
                std::mem::take(&mut self.kv),
                buf_size,
                net_sender.clone(),
            ));
            // save the chat sender in the coordinator
            self.inst_chat_sender.replace(sender.clone());
            // save the chat sender in the instance
            instance.my_sender.lock().replace(sender);
            // create a net sender for the instance
            let sender = executor::and_connect::<_, NetCmd>(&instance);
            // save the sender in the instance
            self.inst_net_sender.replace(sender);
        }
        // tell the network that the coordinator will handle the connection traffic
        let sender = self.inst_net_sender.as_ref().unwrap().clone();
        send_cmd(net_sender, NetCmd::BindConn(conn_id, sender));
        // let all of the components know that there's a new session for the chat service and how to contact the coordinator
        let sender = self.inst_chat_sender.as_ref().unwrap().clone();
        components.iter().for_each(|c| {
            send_cmd(
                c.sender(),
                ComponentCmd::NewSession(conn_uuid, "ChatService".to_string(), Arc::new(sender.clone())),
            )
        });
    }
fn create_instance ( & mut self , conn_id : NetConnId , buf_size : usize , net_sender : & NetSender , components : & [ ComponentInfo ] ) { // create an instance to handle the connection, the ChatInstance has two instruction sets. // Wire them both to the same instance. // Normally, you'd build a translation to a conn_uuid. let conn_uuid : u128 = conn_id . try_into ( ) . unwrap ( ) ; if self . inst_chat_sender . is_none ( ) { // get the instance running let ( instance , sender ) = executor :: connect :: < _ , ChatCmd > ( ChatInstance :: new ( conn_uuid , std :: mem :: take ( & mut self . kv ) , buf_size , net_sender . clone ( ) , ) ) ; // save the chat sender in the coordinator self . inst_chat_sender . replace ( sender . clone ( ) ) ; // save the chat sender in the instance instance . my_sender . lock ( ) . replace ( sender ) ; // create a net sender for the instance let sender = executor :: and_connect :: < _ , NetCmd > ( & instance ) ; // save the sender in the instance self . inst_net_sender . replace ( sender ) ; } // tell the network that the coordinator will handle the connection traffic let sender = self . inst_net_sender . as_ref ( ) . unwrap ( ) . clone ( ) ; send_cmd ( net_sender , NetCmd :: BindConn ( conn_id , sender ) ) ; // let all of the components know that there's a new session for the chat service and how to contact the coordinator let sender = self . inst_chat_sender . as_ref ( ) . unwrap ( ) . clone ( ) ; components . iter ( ) . for_each ( | c | { send_cmd ( c . sender ( ) , ComponentCmd :: NewSession ( conn_uuid , " " . to_string ( ) , Arc :: new ( sender . clone ( ) ) ) , ) } ) ; }
create a coordinator it it hasn't already been created.
create a coordinator it it hasn ' t already been created .
&mut self
conn_id
NetConnId
buf_size
usize
net_sender
&NetSender
components
&[ComponentInfo]