Is it happening on debug mode or release mode?
It is happening on release mode, if I comment the disabling and enabling of buttons everything works all right!!
If the server sends an ack object along with the message then you can use
Sub socket_notify(message As Object, ack As Object)
if the server sends only message then the signature will be
Sub socket_notify(message As Object)
Check your server code.
Thanks, that helped!!!
it works now!!
[CODE lang="b4x" title="Edited code"]#Region Project Attributes
#ApplicationLabel: Socket.IO Simple Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#BridgeLogger : True
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim socket As SocketIOClient
Private StatusLbl As Label
Private SendBtn As Button
Private AckLbl As Label
Private MsgInput As EditText
Private ConnectBtn As Button
Private DisconnectBtn As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ConnectBtn_Click
socket.initialize("socket")
socket.connect("http://11.0.0.139:999/","",False)
'socket.connectWithOptions("https://192.168.0.103:999/","", True,True, 0,1000,5000,20000) 'connect with options
StatusLbl.Text = "Connecting"
End Sub
Sub DisconnectBtn_Click
socket.disconnect()
StatusLbl.Text = "Disconnecting"
End Sub
Sub socket_OnConnect
socket.addEvent("new_message","notify")
StatusLbl.Text = "Connected"
' DisconnectBtn.Enabled = True
' Log("DisconnectBtn enable true")
' SendBtn.Enabled = True
' Log("SendBtn enable true")
' MsgInput.Enabled = True
' Log("MsgInput enable true")
' ConnectBtn.Enabled = False
' Log("ConnectBtn enable false")
End Sub
Sub socket_OnDisconnect(Reason As Object)
socket.removeEvent("new_message","notify")
StatusLbl.Text = "Disconnected"
' ConnectBtn.Enabled = True
' Log("ConnectBtn enable true")
' SendBtn.Enabled = False
' Log("SendBtn enable true")
' MsgInput.Enabled = False
' Log("SendBtn enable false")
' DisconnectBtn.Enabled = False
' Log("DisconnectBtn enable false")
End Sub
Sub socket_notify(message As Object) ', ack As Object
' socket.sendAck(ack,Array("your data"))
Log("socket_notify="&message)
End Sub
Sub SendBtn_Click
socket.emit("user_msg", MsgInput.Text)
End Sub
' Recibimos el callback del servidor
Sub user_msg_ack(data As Object)
AckLbl.Text = data
Log("user_msg_ack="&data)
End Sub[/CODE]