added message_from_user socket
This commit is contained in:
parent
2ecfa708e6
commit
9aa03fc03f
@ -45,6 +45,8 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
SocketHandler.getSocket()
|
SocketHandler.getSocket()
|
||||||
.on("message_from_jarvis") { SocketHandler.messageFromJarvis(it, uiState) }
|
.on("message_from_jarvis") { SocketHandler.messageFromJarvis(it, uiState) }
|
||||||
|
SocketHandler.getSocket()
|
||||||
|
.on("message_from_user") { SocketHandler.messageFromUser(it, uiState) }
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
@ -208,6 +208,8 @@ fun processAudio(audioFile: File): String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun processMessage(text: String, navController: NavController, uiState: ConversationUiState) {
|
fun processMessage(text: String, navController: NavController, uiState: ConversationUiState) {
|
||||||
|
uiState.addMessage(Message(false, text))
|
||||||
|
|
||||||
navController.context.mainExecutor.execute {
|
navController.context.mainExecutor.execute {
|
||||||
SocketHandler.processMessage(
|
SocketHandler.processMessage(
|
||||||
text,
|
text,
|
||||||
@ -217,8 +219,6 @@ fun processMessage(text: String, navController: NavController, uiState: Conversa
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
uiState.addMessage(Message(false, text))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,4 +57,12 @@ object SocketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun messageFromUser(data: Array<Any>, uiState: ConversationUiState) {
|
||||||
|
if (data[0].toString().contains("data")) {
|
||||||
|
val result: JSONObject = data[0] as JSONObject
|
||||||
|
uiState.addMessage(Message(false, result.getString("data")))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user