1
0
mirror of https://github.com/dani/vroom.git synced 2024-06-18 12:19:13 +02:00

Unicast messages on the signaling channel if needed

Fix #99
This commit is contained in:
Daniel Berteaud 2015-03-17 17:47:34 +01:00
parent bc544256da
commit 511a996679

View File

@ -1064,12 +1064,24 @@ websocket '/socket.io/:ver/websocket/:id' => sub {
# We have a message from a peer
elsif ($msg->{data}->{name} eq 'message'){
$self->app->log->debug("Signaling message received from peer " . $id);
# Forward this message to all other members of the same room
$msg->{data}->{args}[0]->{from} = $id;
$self->signal_broadcast_room({
from => $id,
msg => Protocol::SocketIO::Message->new(%$msg)
});
my $to = $msg->{data}->{args}[0]->{to};
# Unicast message ? Check the dest is in the same room
# and send
if ($to &&
$peers->{$to} &&
$peers->{$to}->{room} &&
$peers->{$to}->{room} eq $peers->{$id}->{room} &&
$peers->{$to}->{socket}){
$peers->{$to}->{socket}->send(Protocol::SocketIO::Message->new(%$msg));
}
# No dest, multicast this to every memebrs of the room
else{
$self->signal_broadcast_room({
from => $id,
msg => Protocol::SocketIO::Message->new(%$msg)
});
}
}
# When a peer share its screen
elsif ($msg->{data}->{name} eq 'shareScreen'){