Fixing bug with redis.
This commit is contained in:
parent
c0acc2ee55
commit
370e6f536c
@ -14,7 +14,7 @@ use Data::Dumper;
|
||||
use LasTres::Redis;
|
||||
use LasTres::Controller::Websocket::InputPackets;
|
||||
|
||||
my %sessions;
|
||||
our %SESSIONS;
|
||||
use LasTres::DAO::PJs;
|
||||
my $result_set_pjs = LasTres::DAO::PJs->ResultSet;
|
||||
|
||||
@ -32,12 +32,12 @@ sub ws ($self) {
|
||||
);
|
||||
}
|
||||
my $session_uuid = create_uuid_string;
|
||||
$sessions{$session_uuid} = {
|
||||
$SESSIONS{$session_uuid} = {
|
||||
user => $user,
|
||||
controller => $self,
|
||||
uuid => $session_uuid,
|
||||
};
|
||||
my $session = $sessions{$session_uuid};
|
||||
my $session = $SESSIONS{$session_uuid};
|
||||
$self->on(
|
||||
json => sub ( $self, $hash ) {
|
||||
$self->_handle_packet( $session, $hash );
|
||||
@ -45,7 +45,12 @@ sub ws ($self) {
|
||||
);
|
||||
$self->on(
|
||||
finish => sub ( $self, $code, $reason ) {
|
||||
delete $sessions{$session_uuid};
|
||||
if (defined $session->{redis} && defined $session->{pj}) {
|
||||
my $redis = $session->{redis};
|
||||
my $pj = $session->{pj};
|
||||
$redis->pubsub->unlisten($redis->pj_subscription($pj));
|
||||
}
|
||||
delete $SESSIONS{$session_uuid};
|
||||
$reason ||= "No reason";
|
||||
say STDERR
|
||||
"Websocket for user @{[$user->username]} closed with status $code and reason $reason.";
|
||||
|
@ -14,7 +14,6 @@ use Moo;
|
||||
use JSON qw/to_json from_json/;
|
||||
|
||||
use LasTres::Flags;
|
||||
use LasTres::Redis;
|
||||
use LasTres::DAO::PJs;
|
||||
|
||||
with 'LasTres::Controller::Websocket::InputPacket';
|
||||
@ -83,9 +82,7 @@ sub handle ( $self, $ws, $session, $data ) {
|
||||
clear => $JSON::true,
|
||||
);
|
||||
$info_packet_to_send->send($ws);
|
||||
require LasTres::Redis;
|
||||
my $redis = LasTres::Redis->new;
|
||||
say $redis->pj_subscription($pj);
|
||||
$redis->subscribe($redis->pj_subscription($pj), my $save = sub($message, $topic, $topics) {
|
||||
return $self->_on_redis_event($ws, $session, $message, $topic, $topics);
|
||||
});
|
||||
|
@ -64,7 +64,7 @@ sub handle ( $self, $ws, $session, $data ) {
|
||||
my $info_packet_to_send =
|
||||
LasTres::Controller::Websocket::OutputPacket::Info->new(
|
||||
location_data => {
|
||||
current => $location->hash,
|
||||
current => $team->location->hash,
|
||||
connected_places => $connected_places,
|
||||
},
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user