DoubangoTelecom / sipml5

The world's first HTML5 SIP client (WebRTC)
BSD 3-Clause "New" or "Revised" License
939 stars 456 forks source link

Does SIPML5 work on reactJS #315

Open ghost opened 5 years ago

ghost commented 5 years ago

Hello,

I am building a web app using reactJS and I want to add audio and video functionality to it. I added sipml5 package using yarn, but when I initialized the engine like so:

import SIPml from 'sipml' export default class AppContainer extends Component { constructor(props) { super(props); this.state = { registerSession: null, callSession: null, sipStack: null }; SIPml.init(this.ready, this.error).bind(this); }

I get the error:

TypeError: __WEBPACK_IMPORTED_MODULE_7_sipml___default.a.init is not a function new AppContainer src/components/app/AppContainer.js:41 38 | callSession: null, 39 | sipStack: null 40 | };

41 | SIPml.init(this.ready, this.error).bind(this); 42 | }

BruceYuj commented 5 years ago

you can‘’t use import module syntax to use sipml5. you should use <script> in the root.

RicardoSouzaMoura commented 5 years ago

Put the code inside the index.html and use window.XXX to call the methods from the API.

ofito commented 5 years ago

Like @RicardoSouzaMoura said, just import const SIPml = window.SIPml; and you can use it without problem.