Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. use std::net::TcpStream;
  2.  
  3. struct Client {
  4. stream: TcpStream,
  5. server: Server,
  6. }
  7.  
  8. impl Client {
  9. fn test(&self){
  10. server.broadcast();
  11. }
  12. }
  13.  
  14. struct Server {
  15. conns: Vec<Client>,
  16. }
  17.  
  18. impl Server {
  19. fn add_conn(&mut self, stream: TcpStream){
  20. // do stuff
  21.  
  22. self.conns.push(Client { stream: stream, server: /* What do I do here? */ });
  23. }
  24.  
  25. fn broadcast(&self){
  26. for conn in conns{
  27. // do stuff
  28. }
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement