Paste #144490

   
pasted on 11.09.2020 11:14
  • Edit to this paste
  • Print
  • Raw
  • Compare it with the parent paste
  • Look at the parent paste
  • The following pastes replied to this paste:  # 144491
  • Show paste tree
  • Compare with paste
    #  
  • Toggle line numbers
  • Syntax highlighting  
Text paste
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
sub ws_feed {
  my $ws = shift;
  #~ $ws->inactivity_timeout(300);# переподключение вебсокета
  my $feed = $ws->param('feed')
    or return $ws->send("none param feed?");
  
  $ws->log->error("Client connect try feed=$feed, but feeds=[@{[ keys %{ $ws->app->feeds} ]}]");
  
  $feed = $ws->app->feeds->{$feed}
    or return $ws->send("yet none feed ".$ws->param('feed'));

  my $id = "$ws";
  $ws->log->error("Client connected: $id; to feed tx=".$feed->{tx},);
  $feed->{clients}{$id} = $ws;
  $ws->tx->with_protocols('binary');
  
  $ws->on(
    finish => sub {
      my( $ws, $code, $reason ) = @_ ;
      my $id = "$ws";
      $ws->log->error("Client disconnected: $id");
      delete $feed->{clients}{ $id };
    }
  );
}
Add Comment
Author