1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use crate::japrotocol::Jsep;
use serde_json::json;
use serde_json::Value;
pub struct HandleMessage {
pub session_id: u64,
pub handle_id: u64,
pub body: Value,
}
impl HandleMessage {
/// Full `message` envelope including `session_id`/`handle_id`, used by transports
/// that carry these in the payload (WebSocket, Socket.IO).
pub(crate) fn to_message_envelope(&self) -> Value {
json!({
"janus": "message",
"session_id": self.session_id,
"handle_id": self.handle_id,
"body": self.body,
})
}
/// Body-only `message` envelope, used by the RESTful transport where
/// `session_id`/`handle_id` are carried in the URL.
pub(crate) fn to_message_body(&self) -> Value {
json!({
"janus": "message",
"body": self.body,
})
}
}
pub struct HandleMessageWithJsep {
pub session_id: u64,
pub handle_id: u64,
pub body: Value,
pub jsep: Jsep,
}
impl HandleMessageWithJsep {
/// Full `message` envelope including `session_id`/`handle_id` and `jsep`, used by
/// transports that carry these in the payload (WebSocket, Socket.IO).
pub(crate) fn to_message_envelope(&self) -> Value {
json!({
"janus": "message",
"session_id": self.session_id,
"handle_id": self.handle_id,
"body": self.body,
"jsep": self.jsep,
})
}
/// Body-only `message` envelope including `jsep`, used by the RESTful transport
/// where `session_id`/`handle_id` are carried in the URL.
pub(crate) fn to_message_body(&self) -> Value {
json!({
"janus": "message",
"body": self.body,
"jsep": self.jsep,
})
}
}