All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlinx.jupyter.messaging.MessageFactoryImpl.kt Maven / Gradle / Ivy

There is a newer version: 0.12.0-356
Show newest version
package org.jetbrains.kotlinx.jupyter.messaging

import kotlinx.serialization.json.jsonPrimitive
import org.jetbrains.kotlinx.jupyter.api.libraries.RawMessage

class MessageFactoryImpl : MessageFactory {
    private var _messageId: List = listOf(byteArrayOf(1))
    override val messageId: List
        get() = _messageId

    private var _sessionId = ""
    override val sessionId: String
        get() = _sessionId

    private var _username = ""
    override val username: String
        get() = _username

    private var _contextMessage: RawMessage? = null
    override val contextMessage: RawMessage?
        get() = _contextMessage

    override fun updateSessionInfo(message: RawMessage) {
        val header = message.header
        header["session"]?.jsonPrimitive?.content?.let { _sessionId = it }
        header["username"]?.jsonPrimitive?.content?.let { _username = it }
        _messageId = message.id
    }

    override fun updateContextMessage(contextMessage: RawMessage?) {
        _contextMessage = contextMessage
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy