>()
- val session : PersistentSessionBase = this
- override fun run(userMessage: String) {
- val operationID = ChatSession.randomID()
- val sessionDiv = newSessionDiv(operationID, SkyenetSessionServerBase.spinner)
- val thread = Thread {
- playSempaphores[operationID] = Semaphore(0)
- try {
- processMessage(sessionId, userMessage, session, object : SessionUI {
- override val spinner: String get() = """${SkyenetSessionServerBase.spinner}
"""
- override val playButton: String get() = """"""
- override val cancelButton: String get() = """"""
- override val regenButton: String get() = """"""
-
- override fun hrefLink(handler:Consumer): String {
- val operationID = ChatSession.randomID()
- linkTriggers[operationID] = handler
- return """"""
- }
-
- override fun textInput(handler:Consumer): String {
- val operationID = ChatSession.randomID()
- txtTriggers[operationID] = handler
- //language=HTML
- return """""".trimIndent()
- }
-
- }, sessionDiv)
- } catch (e: Throwable) {
- e.printStackTrace()
- } finally {
- }
- }
- threads[operationID] = thread
- thread.start()
- }
-
- override fun onCmd(id: String, code: String) {
- if(code=="run") {
- playSempaphores[id]?.release()
- }
- if(code=="cancel") {
- threads[id]?.interrupt()
- }
- if(code=="regen") {
- regenTriggers[id]?.accept(Unit)
- }
- if(code.startsWith("link")) {
- linkTriggers[id]?.accept(Unit)
- }
- if(code.startsWith("userTxt,")) {
- txtTriggers[id]?.accept(code.substring("userTxt,".length))
- }
- super.onCmd(id, code)
- }
- }
- handler.setDelegate(basicChatSession)
+ handler.setDelegate(MacroChatSession(this,sessionId))
return handler
}
diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/body/SkyenetSessionServerBase.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/body/SkyenetSessionServerBase.kt
index 04c2c1bb..51ea27b3 100644
--- a/webui/src/main/kotlin/com/simiacryptus/skyenet/body/SkyenetSessionServerBase.kt
+++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/body/SkyenetSessionServerBase.kt
@@ -145,19 +145,18 @@ abstract class SkyenetSessionServerBase(
}
})
- protected open val sessionList = ServletHolder(
- "sessionList",
- object : HttpServlet() {
- override fun doGet(req: HttpServletRequest, resp: HttpServletResponse) {
- resp.contentType = "text/html"
- resp.status = HttpServletResponse.SC_OK
- val links = sessionDataStorage.listSessions().joinToString("
") {
- """
+ inner class SessionServlet : HttpServlet() {
+ override fun doGet(req: HttpServletRequest, resp: HttpServletResponse) {
+ resp.contentType = "text/html"
+ resp.status = HttpServletResponse.SC_OK
+ val sessions = sessionDataStorage.listSessions()
+ val links = sessions.joinToString("
") {
+ """
|${sessionDataStorage.getSessionName(it)}
|
""".trimMargin()
- }
- resp.writer.write(
- """
+ }
+ resp.writer.write(
+ """
|
|
|Sessions
@@ -167,26 +166,32 @@ abstract class SkyenetSessionServerBase(
|
|
""".trimMargin()
+ )
+ }
+ }
+ protected open val sessionList = ServletHolder(
+ "sessionList",
+ SessionServlet()
+ )
+
+
+ inner class AppInfoServlet : HttpServlet() {
+ override fun doGet(req: HttpServletRequest, resp: HttpServletResponse) {
+ resp.contentType = "text/json"
+ resp.status = HttpServletResponse.SC_OK
+ resp.writer.write(
+ JsonUtil.objectMapper().writeValueAsString(
+ mapOf(
+ "applicationName" to applicationName
+ )
)
- }
- })
-
-
+ )
+ }
+ }
protected open val appInfo = ServletHolder(
"appInfo",
- object : HttpServlet() {
- override fun doGet(req: HttpServletRequest, resp: HttpServletResponse) {
- resp.contentType = "text/json"
- resp.status = HttpServletResponse.SC_OK
- resp.writer.write(
- JsonUtil.objectMapper().writeValueAsString(
- mapOf(
- "applicationName" to applicationName
- )
- )
- )
- }
- })
+ AppInfoServlet()
+ )
companion object {
val logger = org.slf4j.LoggerFactory.getLogger(SkyenetSessionServerBase::class.java)