Открыть боковую панель
Aurora OS
Kotlin Multiplatform
Libraries
ktor
Коммиты
2b56035c
Коммит
2b56035c
создал
Фев 04, 2019
по автору
Leonid Stashevsky
Просмотр файлов
Fix race in websocket close
владелец
c2d53b39
Изменения
3
Скрыть пробелы
Построчно
Рядом
ktor-features/ktor-websockets/jvm/src/io/ktor/websocket/Routing.kt
Просмотр файла @
2b56035c
...
@@ -116,8 +116,11 @@ private fun Route.webSocketProtocol(protocol: String?, block: Route.() -> Unit)
...
@@ -116,8 +116,11 @@ private fun Route.webSocketProtocol(protocol: String?, block: Route.() -> Unit)
private
suspend
fun
WebSocketServerSession
.
proceedWebSocket
(
handler
:
suspend
DefaultWebSocketServerSession
.()
->
Unit
)
{
private
suspend
fun
WebSocketServerSession
.
proceedWebSocket
(
handler
:
suspend
DefaultWebSocketServerSession
.()
->
Unit
)
{
val
webSockets
=
application
.
feature
(
WebSockets
)
val
webSockets
=
application
.
feature
(
WebSockets
)
val
session
=
val
session
=
DefaultWebSocketSessionImpl
(
DefaultWebSocketSessionImpl
(
this
,
webSockets
.
pingInterval
?.
toMillis
()
?:
-
1L
,
webSockets
.
timeout
.
toMillis
())
this
,
webSockets
.
pingInterval
?.
toMillis
()
?:
-
1L
,
webSockets
.
timeout
.
toMillis
()
)
session
.
run
{
session
.
run
{
try
{
try
{
toServerSession
(
call
).
handler
()
toServerSession
(
call
).
handler
()
...
...
ktor-features/ktor-websockets/jvm/test/io/ktor/tests/websocket/WebSocketEngineSuite.kt
Просмотр файла @
2b56035c
...
@@ -245,7 +245,7 @@ abstract class WebSocketEngineSuite<TEngine : ApplicationEngine, TConfiguration
...
@@ -245,7 +245,7 @@ abstract class WebSocketEngineSuite<TEngine : ApplicationEngine, TConfiguration
@Test
@Test
fun
testProduceMessages
()
{
fun
testProduceMessages
()
{
val
count
=
125
val
count
=
125
val
template
=
(
1
..
count
).
map
{
(
it
and
0x0f
).
toString
(
16
)
}
.
joinToString
(
""
)
val
template
=
(
1
..
count
).
joinToString
(
""
)
{
(
it
and
0x0f
).
toString
(
16
)
}
createAndStartServer
{
createAndStartServer
{
webSocket
(
"/"
)
{
webSocket
(
"/"
)
{
...
...
ktor-http/ktor-http-cio/jvm/src/io/ktor/http/cio/websocket/DefaultWebSocketSessionImpl.kt
Просмотр файла @
2b56035c
...
@@ -64,7 +64,7 @@ class DefaultWebSocketSessionImpl(
...
@@ -64,7 +64,7 @@ class DefaultWebSocketSessionImpl(
else
->
CloseReason
(
CloseReason
.
Codes
.
UNEXPECTED_CONDITION
,
cause
.
message
?:
cause
.
javaClass
.
name
)
else
->
CloseReason
(
CloseReason
.
Codes
.
UNEXPECTED_CONDITION
,
cause
.
message
?:
cause
.
javaClass
.
name
)
}
}
sendCloseSequence
(
reason
)
reason
?.
let
{
send
(
Frame
.
Close
(
it
))
}
}
}
@UseExperimental
(
ExperimentalCoroutinesApi
::
class
,
ObsoleteCoroutinesApi
::
class
)
@UseExperimental
(
ExperimentalCoroutinesApi
::
class
,
ObsoleteCoroutinesApi
::
class
)
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать