title: Rust Actix Actor send message to actor
body: <p>How to send a message to another actor?</p>
  <pre><code>
  pub struct MyWs {
  }
  
  impl Actor for MyWs {
      type Context = ws::WebsocketContext&lt;Self&gt;;
  }
  
  impl StreamHandler&lt;Result&lt;ws::Message, ws::ProtocolError&gt;&gt; for MyWs {
      fn handle(&amp;mut self, msg: Result&lt;ws::Message, ws::ProtocolError&gt;, ctx: &amp;mut Self::Context) {
          match msg {
              Ok(ws::Message::Ping(msg)) =&gt; ctx.pong(&amp;msg),
              Ok(ws::Message::Text(message)) =&gt; {
  
                  //considering that here he sent the message to self
                  ctx.text(message);
  
                  //how to do something like this
                  //find the actor by index (or uuid) and send text
                  //actors[0].text(message);
                  //
              },
              Ok(ws::Message::Binary(bin)) =&gt; ctx.binary(bin),
              Ok(ws::Message::Close(reason)) =&gt; ctx.close(reason),
              _ =&gt; (),
          }
      }
  }
  
  
  #[get(&quot;/ws&quot;)]
  pub async fn websocket(req: HttpRequest, stream: web::Payload,) -&gt; actix_web::Result&lt;HttpResponse&gt; {
      let resp = ws::start(
          MyWs {},
          &amp;req,
          stream,
      );
      return resp;
  }
  
  </code></pre>
  <p>Could I make a hashMap of actors?</p>
  <pre><code>pub struct MyWs { sessions: HashMap&lt;Uuid, Socket&gt; }
  </code></pre>
  <p>and later</p>
  <pre><code>self.sessions.text(message)
  </code></pre>
  <p>I'm new to rust and I don't see a way to save the socket (the context or actor) to find it and send it messages.</p>