Socket.on triggered succesfully after first emit but not on second emit, #4735
Unanswered
talhakhange
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am connecting the socket io successfully and also listener event triggered get the response on first emit but when i emit another object onNewMessage not triggered,at server side socket successfully responded but onNewMessage not triggered.
`class MainActivity : AppCompatActivity() { var mSocket: Socket? = null var url: String = "https://brainbehind.co:1000"
var button: Button? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val opts = IO.Options()
opts.transports = arrayOf(WebSocket.NAME)
mSocket = IO.socket(url, opts)
//listener event to get response from the server
mSocket?.on("reply_from_bot", onNewMessage)
}
//This is the listener to collect the response, it is triggered and print the response first time but when i emit mSocket?.emit("send_msg_to_bot", obj) , it is not triggered, but when i see the server side socket response successfully triggered but i am not able to listen in this event, also tried to make another event but does not work for me also private val onNewMessage = Emitter.Listener { args -> runOnUiThread(Runnable {
}
onNewMessage event triggered correctly after this mSocket?.emit("connect_client_to_bot", obj) but not triggered after this mSocket?.emit("send_msg_to_bot", obj) even server gives response correctly.stuck in this from last weak, also created a new socket.on() event but this was also not worked.
Beta Was this translation helpful? Give feedback.
All reactions