Search code examples
azure-communication-services

Azure Communication Services Web Calling in MVC


All of the examples for ACS are using Nodejs and VS Code... and thats fine if you're building a new app, and if you have some kind of background with React. I do not... and I'm willing to bet most web devs maintaining and builing MVC apps don't.

I'm not so daft that I can't get a Nodejs app working, I can get the web calling hero sample to run without any issues...

However, I think for MVC we probably should be looking at this solution https://github.com/Azure/communication-ui-library/tree/main/samples/StaticHtmlComposites

and I can't get it going... Not only that... but even if I did get it running how would one implement into an existing MVC app...

Has anyone successfully implemented ACS web calling/video into an existing MVC app, and how did you do it? ...the internet is currently a barren wasteland when it comes to this topic.


Solution

  • ANSWER as of 7/7/2021

    Step 1: Follow all of the steps from here https://github.com/Azure/communication-ui-library/tree/main/samples/StaticHtmlComposites

    Step 2: Take the newly created/bundled callComposite.js file and add it to your existing or new MVC web project. I added mine to wwwroot/js...

    Step 3: Create a view (however you choose to do that...) and copy the html and javascript from the index page in the project I linked to above. (if you don't care about chat you can remove all the related js). You'll need to replace the callComposite.js script link with the newly added one.

    Step 4: You need a controller that will generate the token and userId. I created a web api controller so that a new token and userId was generated essentially when the page was loaded. NOTE: make sure you're using async javascript OR just put the callAdapter code block in a timeout (mine is 2 seconds with a loading screen) Secondary Note: I got all of the code from the Web Calling Hero Sample out of the calling/controllers/UserTokenController.cs

    Final step: say a small prayer, cross your fingers, grab a rabbits foot and rub it. then run it and it could/might/probably/possibly work the first time... but probably not. you'll need to adjust for your own set up.

    For you future people. Please post an updated solution. This is literally the only resource for Azure Communication Services Web Calling on MVC on the internet (as of the time of this posting). Be a hero, tell us a better, easier way.