im following the sample on websockets (<https://gi...
# ktor
h
im following the sample on websockets (https://github.com/ktorio/ktor-samples/blob/master/app/chat/src/ChatApplication.kt) and there is this code block:
Copy code
intercept(ApplicationCallPipeline.Features) {
            if (call.sessions.get<ChatSession>() == null) {
                call.sessions.set(ChatSession(nextNonce()))
            }
        }
although, the class?
ApplicationCallPipeline.Features
is not found (But
ApplicationCallPipeline
is. I am lead to believe that i am missing some dependency which contains this, but i am not entirely sure which one. here are my ependencies:
Copy code
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    compile "io.ktor:ktor-server-netty:$ktor_version"
    compile "ch.qos.logback:logback-classic:$logback_version"
    compile "io.ktor:ktor-server-core:$ktor_version"
    compile "io.ktor:ktor-server-host-common:$ktor_version"
    compile "io.ktor:ktor-websockets:$ktor_version"
    compile "io.ktor:ktor-jackson:$ktor_version"
o
are you using ktor 0.9.5?
the
Features
phase was added in that version
h
i was on 0.9.3! that was the cause of the issue. thank you. also, can you help me understand what the intercept block of code does exactly? I don’t 100% understand.
o
it registers a callback with the
ApplicationCallPipeline
that runs when the specified phase runs. you can see the order by looking at the source for the Pipeline (https://github.com/ktorio/ktor/blob/master/ktor-server/ktor-server-core/src/io/ktor/application/ApplicationCallPipeline.kt#L10)
basically it allows you to modify requests at a specific time
h
ok.. ill look into it.
o
if you want to know more, perhaps read https://ktor.io/advanced/pipeline
h
okay thanks.