I'm trying the example WebApp Chatroom.
ChatShared routine:
It does not use the parameter Name, but I thought to use it this way,
changing the call:
Chat routine:
but I get this server error:
java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:456)
at anywheresoftware.b4a.keywords.Common.access$0(Common.java:427)
at anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Common.java:501)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:195)
...
...
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at b4j.example.chat.callSub(chat.java:146)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:431)
... 10 more
[P.S. the aim is to detect that the message received was sent by "themselves".
(I could get this from the message, I know, but I do not understand, the error seems to be the use of CallSubDelayed3 instead of CallSubDelayed2)]
ChatShared routine:
B4X:
Public Sub NewMessage(Name As String, msg As String)
LastMessages.Add(msg)
If LastMessages.Size > 10 Then
LastMessages.RemoveAt(0)
End If
'notify each of the connected users about the new message
For Each c As Chat In connections.Values
CallSubDelayed2(c, "NewMessage", msg)
Next
End Sub
It does not use the parameter Name, but I thought to use it this way,
changing the call:
B4X:
CallSubDelayed3(c, "NewMessage", msg, Name)
Chat routine:
B4X:
Sub NewMessage(Msg As String, Writer As String)
ChatTxt.RunMethod("append", Array As Object(Msg))
ws.RunFunction("scrollDown", Null)
ws.Flush
If Writer <> name Then ' name is a module variable that holds the name of the chatter
' do something because you are not the sender
End If
End Sub
but I get this server error:
java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:456)
at anywheresoftware.b4a.keywords.Common.access$0(Common.java:427)
at anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Common.java:501)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:195)
...
...
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at b4j.example.chat.callSub(chat.java:146)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:431)
... 10 more
[P.S. the aim is to detect that the message received was sent by "themselves".
(I could get this from the message, I know, but I do not understand, the error seems to be the use of CallSubDelayed3 instead of CallSubDelayed2)]
Last edited: