Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
93c9367e
提交
93c9367e
authored
8月 21, 2021
作者:
Nazar Mokrynskyi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Minor refactoring
上级
6b0acc44
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
35 行删除
+20
-35
channel.rs
rust/src/worker/channel.rs
+7
-12
payload_channel.rs
rust/src/worker/payload_channel.rs
+13
-23
没有找到文件。
rust/src/worker/channel.rs
浏览文件 @
93c9367e
...
@@ -3,7 +3,7 @@ use crate::worker::common::{EventHandlers, SubscriptionTarget, WeakEventHandlers
...
@@ -3,7 +3,7 @@ use crate::worker::common::{EventHandlers, SubscriptionTarget, WeakEventHandlers
use
crate
::
worker
::{
RequestError
,
SubscriptionHandler
};
use
crate
::
worker
::{
RequestError
,
SubscriptionHandler
};
use
async_executor
::
Executor
;
use
async_executor
::
Executor
;
use
async_fs
::
File
;
use
async_fs
::
File
;
use
bytes
::
{
BufMut
,
Bytes
,
BytesMut
}
;
use
bytes
::
Bytes
;
use
futures_lite
::
io
::
BufReader
;
use
futures_lite
::
io
::
BufReader
;
use
futures_lite
::{
future
,
AsyncReadExt
,
AsyncWriteExt
};
use
futures_lite
::{
future
,
AsyncReadExt
,
AsyncWriteExt
};
use
log
::{
debug
,
trace
,
warn
};
use
log
::{
debug
,
trace
,
warn
};
...
@@ -372,19 +372,14 @@ impl Channel {
...
@@ -372,19 +372,14 @@ impl Channel {
debug!
(
"request() [method:{}, id:{}]: {}"
,
method
,
id
,
message
);
debug!
(
"request() [method:{}, id:{}]: {}"
,
method
,
id
,
message
);
let
bytes
=
{
let
bytes
=
Bytes
::
from
(
let
mut
bytes
=
BytesMut
::
new
()
.writer
();
serde_json
::
to_vec
(
&
RequestMessagePrivate
{
serde_json
::
to_writer
(
&
mut
bytes
,
&
RequestMessagePrivate
{
id
,
id
,
method
,
method
,
message
,
message
,
},
})
)
.unwrap
(),
.unwrap
();
);
bytes
.into_inner
()
};
if
bytes
.len
()
>
NS_PAYLOAD_MAX_LEN
{
if
bytes
.len
()
>
NS_PAYLOAD_MAX_LEN
{
self
.inner
self
.inner
...
@@ -399,7 +394,7 @@ impl Channel {
...
@@ -399,7 +394,7 @@ impl Channel {
self
.inner
self
.inner
.sender
.sender
.send
(
bytes
.freeze
()
)
.send
(
bytes
)
.await
.await
.map_err
(|
_
|
RequestError
::
ChannelClosed
{})
?
;
.map_err
(|
_
|
RequestError
::
ChannelClosed
{})
?
;
...
...
rust/src/worker/payload_channel.rs
浏览文件 @
93c9367e
...
@@ -3,7 +3,7 @@ use crate::worker::common::{EventHandlers, SubscriptionTarget, WeakEventHandlers
...
@@ -3,7 +3,7 @@ use crate::worker::common::{EventHandlers, SubscriptionTarget, WeakEventHandlers
use
crate
::
worker
::{
RequestError
,
SubscriptionHandler
};
use
crate
::
worker
::{
RequestError
,
SubscriptionHandler
};
use
async_executor
::
Executor
;
use
async_executor
::
Executor
;
use
async_fs
::
File
;
use
async_fs
::
File
;
use
bytes
::
{
BufMut
,
Bytes
,
BytesMut
}
;
use
bytes
::
Bytes
;
use
futures_lite
::
io
::
BufReader
;
use
futures_lite
::
io
::
BufReader
;
use
futures_lite
::{
future
,
AsyncReadExt
,
AsyncWriteExt
};
use
futures_lite
::{
future
,
AsyncReadExt
,
AsyncWriteExt
};
use
log
::{
debug
,
error
,
trace
,
warn
};
use
log
::{
debug
,
error
,
trace
,
warn
};
...
@@ -366,19 +366,14 @@ impl PayloadChannel {
...
@@ -366,19 +366,14 @@ impl PayloadChannel {
debug!
(
"request() [method:{}, id:{}]: {}"
,
method
,
id
,
message
);
debug!
(
"request() [method:{}, id:{}]: {}"
,
method
,
id
,
message
);
let
bytes
=
{
let
bytes
=
Bytes
::
from
(
let
mut
bytes
=
BytesMut
::
new
()
.writer
();
serde_json
::
to_vec
(
&
RequestMessagePrivate
{
serde_json
::
to_writer
(
&
mut
bytes
,
&
RequestMessagePrivate
{
id
,
id
,
method
,
method
,
message
,
message
,
},
})
)
.unwrap
(),
.unwrap
();
);
bytes
.into_inner
()
};
if
bytes
.len
()
>
NS_PAYLOAD_MAX_LEN
{
if
bytes
.len
()
>
NS_PAYLOAD_MAX_LEN
{
self
.inner
self
.inner
...
@@ -405,7 +400,7 @@ impl PayloadChannel {
...
@@ -405,7 +400,7 @@ impl PayloadChannel {
self
.inner
self
.inner
.sender
.sender
.send
(
MessageWithPayload
{
.send
(
MessageWithPayload
{
message
:
bytes
.freeze
()
,
message
:
bytes
,
payload
,
payload
,
})
})
.await
.await
...
@@ -465,18 +460,13 @@ impl PayloadChannel {
...
@@ -465,18 +460,13 @@ impl PayloadChannel {
return
Err
(
NotificationError
::
PayloadTooLong
);
return
Err
(
NotificationError
::
PayloadTooLong
);
}
}
let
bytes
=
{
let
bytes
=
Bytes
::
from
(
let
mut
bytes
=
BytesMut
::
new
()
.writer
();
serde_json
::
to_vec
(
&
NotificationMessagePrivate
{
serde_json
::
to_writer
(
&
mut
bytes
,
&
NotificationMessagePrivate
{
event
,
event
,
notification
,
notification
,
},
})
)
.unwrap
(),
.unwrap
();
);
bytes
.into_inner
()
};
if
bytes
.len
()
>
NS_PAYLOAD_MAX_LEN
{
if
bytes
.len
()
>
NS_PAYLOAD_MAX_LEN
{
return
Err
(
NotificationError
::
MessageTooLong
);
return
Err
(
NotificationError
::
MessageTooLong
);
...
@@ -485,7 +475,7 @@ impl PayloadChannel {
...
@@ -485,7 +475,7 @@ impl PayloadChannel {
self
.inner
self
.inner
.sender
.sender
.send
(
MessageWithPayload
{
.send
(
MessageWithPayload
{
message
:
bytes
.freeze
()
,
message
:
bytes
,
payload
,
payload
,
})
})
.await
.await
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论