Compare Pastes
Differences between the pastes
#144490 (11.09.2020 11:14)
and
#276760 (16.08.2024 19:37).
| 1 | sub ws_feed {
| |
| 2 | my $ws = shift; | |
| 3 | #~ $ws->inactivity_timeout(300);# переподключение вебсокета | |
| 1 | Видео о том как грузоподъемный механизм поднимает груз на заданную высоту есть. А вот где видео про то, как это делает Илон Маск? | |
| 2 | ||
| 3 | ||
| 4 | my $feed = $ws->param('feed')
| |
| 5 | or return $ws->send("none param feed?");
| |
| 6 | ||
| 7 | $ws->log->error("Client connect try feed=$feed, but feeds=[@{[ keys %{ $ws->app->feeds} ]}]");
| |
| 8 | ||
| 9 | $feed = $ws->app->feeds->{$feed}
| |
| 10 | or return $ws->send("yet none feed ".$ws->param('feed'));
| |
| 11 | ||
| 12 | my $id = "$ws"; | |
| 13 | $ws->log->error("Client connected: $id; to feed tx=".$feed->{tx},);
| |
| 14 | $feed->{clients}{$id} = $ws;
| |
| 15 | $ws->tx->with_protocols('binary');
| |
| 16 | ||
| 17 | $ws->on( | |
| 18 | finish => sub {
| |
| 19 | my( $ws, $code, $reason ) = @_ ; | |
| 20 | my $id = "$ws"; | |
| 21 | $ws->log->error("Client disconnected: $id");
| |
| 22 | delete $feed->{clients}{ $id };
| |
| 23 | } | |
| 24 | ); |
