4

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.

CSharpMinor
  • 202
  • 1
  • 9
  • I mean at this point, I'd take "wrap in a blazor component on a view" as the correct answer if there was some kind of documentation on where to even start... – CSharpMinor Jul 07 '21 at 03:57

1 Answers1

2

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.

CSharpMinor
  • 202
  • 1
  • 9
  • I'm trying to follow but stuck on step 1. What instructions should I follow? I downloaded the files and there appear to be missing dependencies eg React. I thought it was supposed to be static html pre-bundled? The instructions say to run rush. I attempted to install rush but it said there was an error in a microsoft beta dependency. – mike nelson Jun 23 '23 at 22:10
  • Update: got rush working, i had just mistyped `npm install -g @microsoft/rush`, then ran `rush` and `rushx` commands, it creates a server, i had to change the config file, then it runs but various errors now appear in devtools - `Warning: Invalid hook call. Hooks can only be called inside of the body of a function component`, `Uncaught TypeError: Cannot read properties of null (reading 'useRef')` and `The above error occurred in the component`, any hints? How about just zip up all the final static files? – mike nelson Jun 23 '23 at 22:58
  • Hi @mikenelson! It's been almost 2 years since I wrote this up, so it's probable that MS updated their docs pretty significantly. I've since switched to Twilio JS since it's free. I wish I could give you more details on it, but the best suggestion I can give is to just play with it; it's what I had to do. – CSharpMinor Jun 23 '23 at 23:06
  • Thanks. Yeah I had to give up, its way too complicated! And microsoft have the temerity to state that it can be done in just a couple of lines of code. It requires thousands of open source dependencies to be downloaded, compiled, and debugged. Nothing runs and its too difficult to understand the context of what's broken and how broken it is. – mike nelson Jun 27 '23 at 09:23