tomek-o / tSIP

SIP softphone
https://tomeko.net/software/SIPclient/
155 stars 34 forks source link

Web browser integration - send DTMF #54

Open mark05e opened 5 days ago

mark05e commented 5 days ago

Hi, I was reading https://tomeko.net/software/SIPclient/browser_integration.php and was wondering if there would be a capability send DTMF digits while on a call. This could involve sending either a single digit or a sequence of numbers.

mark05e commented 5 days ago

Experimenting with these on the command line under the assumption that it would be similar experience on the browser - but it does not seem to work.

.\tSIP.exe /tsip=SCRIPT_B64=U2hvd01lc3NhZ2UoIkhlbGxvIGZyb20gd3d3ISIp
.\tSIP.exe /SCRIPT_B64=U2hvd01lc3NhZ2UoIkhlbGxvIGZyb20gd3d3ISIp
tomek-o commented 5 days ago

.\tSIP.exe /tsip=SCRIPT_B64=U2hvd01lc3NhZ2UoIkhlbGxvIGZyb20gd3d3ISIp

@mark05e This one should work, it might be disabled though (there is a log for this case):

tsip-script

Scripts from command line (and thus also from protocol handler) are ignored by default because I've assumed that it might create security issue, especially if one have disabled previously browser warning for a protocol handler.

mark05e commented 5 days ago

Yes that worked! I can run it via command line and browser. Thank you.

You are right about the security concerns.

mark05e commented 1 day ago

@tomek-o, I'm currently working on a project to build a REST API interface for interacting with the tSIP client using Go. I'm learning to code and I'm wondering whether this approach is efficient for interfacing with the tSIP client. I'm creating a HTTP listener to execute REST API commands through the tSIP command line and plan to build a custom web UI for interacting with the web interface. I would greatly appreciate your thoughts on the efficiency of this approach.

tomek-o commented 1 day ago

REST API

@mark05e I have though about it.

First I'd mention https://github.com/voiceip/tinyphone - it looks like a REST-first softphone. I don't know it and there would pros and cons like no GUI (might be a pro, might be a con), but it might be worth checking.

Now for tSIP.

Controlling it via command line has one limitation - it is unidirectional. If you are fine with it, then it might be pretty good choice - easy to debug and language-independent. Usually it would be used with single tSIP instance (new process passes command to previous process if it finds it), but it should work also for multiple instances if different main window names are set.

Something like https://tomeko.net/software/SIPclient/TcpServer/ could be used for bidirectional communication, but for me personally it would be slightly messy (tSIP.exe + script + plugin +TCP/REST translator).

I was thinking of writing a plugin with HTTP (HTTPS?) server for REST-like interface, but I have not found motivation so far. Depending on required functionality, plugin interface might need some expanding too. Only few events are directly passed to plugins at the moment and passing other events requires scripts.

mark05e commented 20 hours ago

Thank you for your feedback. The resources you've shared are interesting. At this time, I'm comfortable with one-way integration for a v0 solution.

In my workflow, I'm testing IVRs and would need "profiles" of different button combinations to run through. I would like to switch between these profiles quickly. The Web UI would help me make quick interfaces that I need. I noticed a small delay in using the registry protocol on my machine and hence decided to go with REST APIs.

I appreciate you taking the time to respond. Wish you the best.

tomek-o commented 9 hours ago

I'm testing IVRs and would need "profiles" of different button combinations to run through. I would like to switch between these profiles quickly.

@mark05e I don't have a right example at the moment (https://tomeko.net/software/SIPclient/howto/flat_GUI/ might be the closest, but probably only the area on the right to the dialpad should be customized), but dynamic user interface can be also created in tSIP directly. Lua SetButtonVisible() function can show/hide specified button. To keep some some order, button control should probably be delegated to a single Lua module (example attached) that would be grouping buttons into views and would be used to switch between views in other scripts (button handlers, call state handlers). Would it be better or worth the effort? I don't know.

Screens.zip (Screens.lua)

mark05e commented 1 hour ago

The solution you shared looks like an option. However I'd still like to use the browser to make my interface as I believe its easier for me to build the interface I want. I'm comfortable using html/js to build basic UIs.

I have figured out a interim solution using shell2http to set up a quick rest interface, pass in Lua commands to tSIP, write some information to a log file, and return the output back to the browser.

Here is an example of what I'd pass to tsip

ShowMessage("Hello from www!")
ShowMessage(_VERSION)
function writelog(message)
    -- Open the log file in append mode
    local file = io.open("log.txt", "a")

    -- Check if file was opened successfully
    if file then
        -- Write the message to the file followed by a newline
        file:write(message .. "\n")

        -- Close the file
        file:close()
    else
        -- Handle error if file cannot be opened
        error("Unable to open log file")
    end
end

writelog("Hello World, Mark")
writelog("Hello World, Mark - Line 2")
writelog("Hello World, Mark - Line 3")
writelog("Hello World, Mark - Line 4")
shell2http.exe /test "C:\tools\tsip\tsip.exe /tsip=SCRIPT_B64=U2hvd01lc3NhZ2UoIkhlbGxvIGZyb20gd3d3ISIpDQpTaG93TWVzc2FnZShfVkVSU0lPTikNCmZ1bmN0aW9uIHdyaXRlbG9nKG1lc3NhZ2UpDQogICAgLS0gT3BlbiB0aGUgbG9nIGZpbGUgaW4gYXBwZW5kIG1vZGUNCiAgICBsb2NhbCBmaWxlID0gaW8ub3BlbigibG9nLnR4dCIsICJhIikNCiAgICANCiAgICAtLSBDaGVjayBpZiBmaWxlIHdhcyBvcGVuZWQgc3VjY2Vzc2Z1bGx5DQogICAgaWYgZmlsZSB0aGVuDQogICAgICAgIC0tIFdyaXRlIHRoZSBtZXNzYWdlIHRvIHRoZSBmaWxlIGZvbGxvd2VkIGJ5IGEgbmV3bGluZQ0KICAgICAgICBmaWxlOndyaXRlKG1lc3NhZ2UgLi4gIlxuIikNCiAgICAgICAgDQogICAgICAgIC0tIENsb3NlIHRoZSBmaWxlDQogICAgICAgIGZpbGU6Y2xvc2UoKQ0KICAgIGVsc2UNCiAgICAgICAgLS0gSGFuZGxlIGVycm9yIGlmIGZpbGUgY2Fubm90IGJlIG9wZW5lZA0KICAgICAgICBlcnJvcigiVW5hYmxlIHRvIG9wZW4gbG9nIGZpbGUiKQ0KICAgIGVuZA0KZW5kDQoNCndyaXRlbG9nKCJIZWxsbyBXb3JsZCwgTWFyayIpDQp3cml0ZWxvZygiSGVsbG8gV29ybGQsIE1hcmsgLSBMaW5lIDIiKQ0Kd3JpdGVsb2coIkhlbGxvIFdvcmxkLCBNYXJrIC0gTGluZSAzIikNCndyaXRlbG9nKCJIZWxsbyBXb3JsZCwgTWFyayAtIExpbmUgNCIp && more C:\tools\tsip\log.txt"

image

image