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

Configure Member's RPC connection settings via Control API (#27) #95

Merged
merged 22 commits into from
Apr 7, 2020
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
Add timeouts to the demo's Control API UI
evdokimovs committed Mar 23, 2020

Verified

This commit was signed with the committer’s verified signature.
commit 01bd8197ec98cc2033f95f2f98d5e50c4bedb9e8
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 24 additions & 7 deletions jason/e2e-demo/js/index.js
Original file line number Diff line number Diff line change
@@ -194,7 +194,25 @@ const controlDebugWindows = {
let memberId = container.getElementsByClassName('control-debug__id_member')[0].value;
let credentials = container.getElementsByClassName('member-spec__credentials')[0].value;

await controlApi.createMember(roomId, memberId, credentials);
let idleTimeout = container.getElementsByClassName('member-spec__idle-timeout')[0].value;
let reconnectionTimeout = container.getElementsByClassName('member-spec__reconnect-timeout')[0].value;
let pingInterval = container.getElementsByClassName('member-spec__ping-interval')[0].value;

let spec = {};
if (credentials.length > 0) {
spec.credentials = credentials;
}
if (idleTimeout.length > 0) {
spec.idle_timeout = idleTimeout;
}
if (reconnectionTimeout.length > 0) {
spec.reconnection_timeout = reconnectionTimeout;
}
if (pingInterval.length > 0) {
spec.ping_interval = pingInterval;
}

await controlApi.createMember(roomId, memberId, spec);
});
},

@@ -543,16 +561,15 @@ const controlApi = {
}
},

createMember: async function(roomId, memberId, credentials) {
createMember: async function(roomId, memberId, spec) {
spec.kind = 'Member';
spec.pipeline = {};

try {
await axios({
method: 'post',
url: controlUrl + roomId + '/' + memberId,
data: {
kind: 'Member',
credentials: credentials,
pipeline: {}
}
data: spec
});
} catch (e) {
alert(JSON.stringify(e.response.data));
5 changes: 5 additions & 0 deletions jason/e2e-demo/video-call.html
Original file line number Diff line number Diff line change
@@ -330,6 +330,11 @@
<input class="control-debug__id_room" placeholder="Room ID">
<input class="control-debug__id_member" placeholder="Member ID">
<input class="member-spec__credentials" placeholder="Credentials">
<br>
<input class="member-spec__idle-timeout" placeholder="IDLE timeout">
<input class="member-spec__reconnect-timeout" placeholder="Reconnect timeout">
<input class="member-spec__ping-interval" placeholder="Ping interval">


<button class="control-debug__execute">Execute</button>
</div>
1 change: 1 addition & 0 deletions mock/control-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ actix-web = "2.0"
clap = "2.33"
dotenv = "0.13"
futures = "0.1"
humantime-serde = "1.0"
tonic = "0.1"
medea-control-api-proto = { path = "../../proto/control-api" }
protobuf = "2.7"
34 changes: 18 additions & 16 deletions mock/control-api/src/api/member.rs
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ use medea_control_api_proto::grpc::api as proto;
use serde::{Deserialize, Serialize};

use super::endpoint::Endpoint;
use std::time::Duration;

/// Entity that represents [Control API] `Member`.
///
@@ -34,18 +35,17 @@ pub struct Member {
#[serde(skip_serializing_if = "Option::is_none")]
on_leave: Option<String>,

#[serde(default = "default_grpc_uint64")]
idle_timeout: u64,
#[serde(default)]
#[serde(with = "humantime_serde")]
idle_timeout: Duration,

#[serde(default = "default_grpc_uint64")]
reconnection_timeout: u64,
#[serde(default)]
#[serde(with = "humantime_serde")]
reconnection_timeout: Duration,

#[serde(default = "default_grpc_uint64")]
ping_interval: u64,
}

fn default_grpc_uint64() -> u64 {
0
#[serde(default)]
#[serde(with = "humantime_serde")]
ping_interval: Duration,
}

impl Member {
@@ -64,9 +64,9 @@ impl Member {
credentials: self.credentials.unwrap_or_default(),
on_join: self.on_join.unwrap_or_default(),
on_leave: self.on_leave.unwrap_or_default(),
idle_timeout: self.idle_timeout,
reconnection_timeout: self.reconnection_timeout,
ping_interval: self.ping_interval,
idle_timeout: self.idle_timeout.as_secs(),
reconnection_timeout: self.reconnection_timeout.as_secs(),
ping_interval: self.ping_interval.as_secs(),
}
}

@@ -93,9 +93,11 @@ impl From<proto::Member> for Member {
credentials: Some(proto.credentials),
on_join: Some(proto.on_join).filter(|s| !s.is_empty()),
on_leave: Some(proto.on_leave).filter(|s| !s.is_empty()),
idle_timeout: proto.idle_timeout,
reconnection_timeout: proto.reconnection_timeout,
ping_interval: proto.ping_interval,
idle_timeout: Duration::from_secs(proto.idle_timeout),
reconnection_timeout: Duration::from_secs(
proto.reconnection_timeout,
),
ping_interval: Duration::from_secs(proto.ping_interval),
}
}
}