I am working on a web app that receives sms messages for a VOIP service. I have it working with a desktop app, but not the web app.
I can see that the app gets data in the debug console:
GET /from=18142070445%26phonenumber=18146955616%26message=Second+test+ HTTP/1.1
but the code: Var TotMessage as String = Self.ReadAll
generates an error…
How do I read the received text message to add it to my text box?
How are you getting that line in debug? I recall your socket is listening on a high port to avoid permissions issues, but if your socket isn’t consuming HTTP correctly you might as well just pass it to the Xojo Web application itself and use the HandleURL event.
Getting the value from a socket to a text box on a Web Session is another challenge since you’ll have to find the correct session and send the data there. I would start by making sure you can get the request handled in the HandleURL event or equivalent for the socket if you use that method.
1 Like
I see the data in the error routine (error reported is 102). The “GET …” data is in mDataBuffer
The program can send an sms message back… if I used the handlurl event, how is the data received read?
I thought the EasyTCPSocket could only talk to other EasyTCPSockets. You may need to use a regular TCPSocket to interact with 3rd party services.
If there is a service making HTTP requests like the one in your example, when it makes a HTTP request to a Web App the HandleURL event is raised. In that event you’d find that the Request
object’s Method
property would say “GET” among other details.
If you have the ability to experiment, it may be worth a go. If you have documentation for how the VOIP service is notifying your application, that would help the community build a more informed answer for you.
Not much in documentation from AnveoDirect… it is an http request, with the example of: Example
https://www.mydomain.com/smscallback?from=$[from]$&phonenumber=$[to]$&message=$[message]$
I have that line at the VOIP provider set to: http://portman.no-ip.biz:8084/from=$[from]$&phonenumber=$[to]$&message=$[message]$
In the handleurl event, I tried to add the line: webMessage.AddMessage(request.Body)
It compiles, but I get a 500 error on the webpage… how do you read / display the information in the handleurl event?
HandleURL operates outside of a session context, so to send the body to a specific session you’ll need to construct a WebSession context. But that’s down the road.
For the URL example you posted, you’ll find in the HandleURL event a Request
object with the Path
“smscallback” and a QueryString
of “from=$[from]$&phonenumber=$[to]$&message=$[message]$”, the other requests you can ignore.
if Request.Path = "smscallback" then
break
Print(Request.QueryString)
end
You would see the output in stdout, or if you’re using Lifeboat the Web App Log, or if you’re in debug mode it should break so you can explore the Request object.
Once you’ve got your SMS notification parsing working, you can use the Example Project in the Example Projects/Platforms/Web/
folder named “Communicating between Sessions.xojo_binary_project” to explore creating a Session context to send messages to.