I have method to calculate the inverse of laplace.
I’m making a websocket to do the calculation and return the value.
This is the calculation that works perfectly.
using InverseLaplace
import InverseLaplace: talbot
try
f = eval(Meta.parse("f(s) = (8 / (8s + 1))*1/s"));
func_invlap = Talbot(f, 2);
println(func_invlap);
println(func_invlap(1));
catch e
println(e)
end
nothing
console log
Talbot{typeof(f)}(Nterms=2)
0.9345344730611376858909718271279009642943857425470905428811143880770099096286615
But this same calculation implemented in the websocket of the error MethodError
# ServerWS takes two functions; the first a http request handler function for page requests,
function coroutine(thisws)
#push!(SocketList, thisws => length(WEBSOCKETS) +1 )
#infolab = InfoLab();
username = ""
while true
# This next call waits for a message to
# appear on the socket. If there is none,
# this task yields to other tasks.
data, success = readguarded(thisws)
!success && break
#global LASTMSG = msg = String(data)
msg = String(data)
println("Received: $msg ")
if startswith(msg, "tf:")
try
f = eval(Meta.parse("f(s) = (8 / (8s + 1))*1/s"));
#func_invlap = Talbot(f, 80);
func_invlap = InverseLaplace.Talbot(f, 2);
println(func_invlap);
println("before calc")
println(func_invlap(1));
catch e
println(e)
end
println("after calc")
end
end
exitmsg = username == "" ? "unknown" : username * " has left"
distributemsg(exitmsg, thisws)
println(exitmsg)
# No need to close the websocket. Just clean up external references:
removereferences(thisws)
nothing
end
# one for opening websockets (which javascript in the HTML page will try to do)
global LASTSERVER = WebSockets.ServerWS(req2resp, gatekeeper)
# Start the server asyncronously, and stop it later
@async WebSockets.serve(LASTSERVER, LOCALIP, HTTPPORT)
console log
Talbot{typeof(f)}(Nterms=5)
MethodError(f, (2.0,), 0x0000000000007ecc)
Can anyone tell me the cause of the error?