Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Implement Control API basic Apply method (#27) #187

Merged
merged 29 commits into from
Apr 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix bug
evdokimovs committed Mar 15, 2021
commit 5e755b6dc60b882bd3f23a24bd94f178e3dd8659
18 changes: 11 additions & 7 deletions src/signalling/room/dynamic_api.rs
Original file line number Diff line number Diff line change
@@ -5,10 +5,7 @@

use std::{collections::HashMap, convert::TryInto as _};

use actix::{
fut, ActorFuture as _, AsyncContext, AtomicResponse, Context, Handler,
Message, WrapFuture as _,
};
use actix::{fut, ActorFuture as _, AsyncContext, AtomicResponse, Context, Handler, Message, WrapFuture as _, ActorFuture};
use medea_client_api_proto::{CloseReason, MemberId, PeerId};
use medea_control_api_proto::grpc::api as proto;

@@ -224,13 +221,16 @@ impl Room {
);

member.insert_sink(sink);
println!("Sink inserted");

Ok(Box::pin(fut::ready(()).map(
move |_, this: &mut Self, ctx| {
let member_id = member.id();
println!("Inti member connection");
if this.members.member_has_connection(&member_id) {
ctx.spawn(this.init_member_connections(&member).map(
move |res, this, ctx| {
println!("Inited");
if let Err(e) = res {
error!(
"Failed to interconnect Members, because \
@@ -401,7 +401,7 @@ impl Handler<ApplyMember> for Room {
fn handle(
&mut self,
msg: ApplyMember,
_: &mut Self::Context,
ctx: &mut Self::Context,
) -> Self::Result {
let mut sids = Sids::new();
if let Ok(member) = self.members.get_member(&msg.0) {
@@ -412,7 +412,9 @@ impl Handler<ApplyMember> for Room {
}
for (id, endpoint) in msg.1.play_endpoints() {
if member.get_sink_by_id(&id).is_none() {
self.create_sink_endpoint(&msg.0, id, endpoint.clone())?;
ctx.spawn(
self.create_sink_endpoint(&msg.0, id, endpoint.clone())?.map(|_, _, _| ())
);
}
}
for id in member.srcs_ids() {
@@ -490,7 +492,9 @@ impl Handler<Apply> for Room {
self.create_src_endpoint(id, src_id, &src)?;
}
for (id, sink_id, sink) in create_sink_endpoint {
self.create_sink_endpoint(&id, sink_id, sink)?;
ctx.spawn(
self.create_sink_endpoint(&id, sink_id, sink)?.map(|_, _, _| ())
);
}

for id in self.members.members_ids() {
24 changes: 12 additions & 12 deletions tests/e2e/features/test/apply.feature
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Feature: Apply method of Control API
# Scenario: Remove Member by apply
# Given room with joined member Alice and Bob
# When Control API removes Alice by apply
# Then Bob's connection with Alice closes
Scenario: Remove Member by apply
Given room with joined member Alice and Bob
When Control API removes Alice by apply
Then Bob's connection with Alice closes

Scenario: Interconnect Members by apply
Given room with joined member Alice and Bob with no WebRTC endpoints
When Control API interconnects Alice and Bob by apply
Then Alice receives connection with Bob
And Bob receives connection with Alice

# Scenario: OnJoin callback fires on interconnection by applying
# Given room with joined member Alice and Bob with no WebRTC endpoints
# When Control API interconnects Alice and Bob by apply
# Then Control API sends `OnJoin` callback for member Alice
Scenario: OnJoin callback fires on interconnection by applying
Given room with joined member Alice and Bob with no WebRTC endpoints
When Control API interconnects Alice and Bob by apply
Then Control API sends `OnJoin` callback for member Alice

# Scenario: `Room.on_close()` fires when room is removed by apply
# Given room with joined member Alice
# When Control API removes Alice by apply
# Then Alice's `on_close` room's callback fires with `Evicted` reason
Scenario: `Room.on_close()` fires when room is removed by apply
Given room with joined member Alice
When Control API removes Alice by apply
Then Alice's `on_close` room's callback fires with `Evicted` reason