Ola
I've just seen this example.
Am I right to assume that the way to handle user sessions also with BANano is
As per this example? and you dont need to have these on your handler page
Thanks
I've just seen this example.
[Server] Guess My Number example
The purpose of this example is to demonstrate how you can interact with the server through ajax requests. The server chooses a number and the user needs to guess the number. Whenever the user presses on the Guess button a request is sent to the Guess handler: Sub Handle(req As...
www.b4x.com
Am I right to assume that the way to handle user sessions also with BANano is
B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
If req.GetSession.HasAttribute("myNumber") = False Then
req.GetSession.SetAttribute("myNumber", Rnd(0, 101)) '<-- store the number in the user session
End If
Dim myNumber As Int = req.GetSession.GetAttribute("myNumber")
Dim n As String = req.GetParameter("number")
If IsNumber(n) = False Then
resp.Write("Please enter a valid number.")
Else
If n > myNumber Then
resp.Write("My number is smaller.")
Else If n < myNumber Then
resp.Write("My number is larger.")
Else
resp.Write("Well done!!!")
End If
End If
End Sub
As per this example? and you dont need to have these on your handler page
B4X:
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
Thanks