问题
I had place call between two Android devices which is running successfully. Now I want to implement Callback Rest API because of some server side decision before place call. As given in this image, ICE event fire and developer backend respond SVAML response.
Now I want to simply Hangup Call, for this I had done following code :
[System.Web.Http.HttpPost]
public SvamletModel MakeCall(CallbackEventModel model)
{
var sinch = SinchFactory.CreateCallbackResponseFactory(Locale.EnUs);
var reader = sinch.CreateEventReader();
var evt = reader.ReadModel(model);
var builder = sinch.CreateIceSvamletBuilder();
SvamletModel svaml = builder.Hangup().Model;
return svaml;
}
but call still placed. I had also write action class under SvamletModel but same response.
[System.Web.Http.HttpPost]
public SvamletModel MakeCall(CallbackEventModel model)
{
var sinch = SinchFactory.CreateCallbackResponseFactory(Locale.EnUs);
var reader = sinch.CreateEventReader();
var evt = reader.ReadModel(model);
var builder = sinch.CreateIceSvamletBuilder();
SvamletModel svaml = builder.Build().Model;
SvamletActionModel actionModel = new SvamletActionModel();
actionModel.Name = "Hangup";
svaml.Action = actionModel;
return svaml;
}
Note I had followed all steps given in Callback API and https://developers.sinch.com/docs/further-securing-your-sinch-calling-functionality-app-with-rest-api with no success.
回答1:
Hi your code looks correct, can you capture and send here the HTTP response your backend is sending as response of the ICE POST? Also add the callID for call.
Sinch Voice & Video Team
回答2:
Converting return type from SvamletModel
to string
is working.
So I have changed
[System.Web.Http.HttpPost]
public SvamletModel MakeCall(CallbackEventModel model)
{
var sinch = SinchFactory.CreateCallbackResponseFactory(Locale.EnUs);
var reader = sinch.CreateEventReader();
var evt = reader.ReadModel(model);
var builder = sinch.CreateIceSvamletBuilder();
SvamletModel svaml = builder.Hangup().Model;
return svaml;
}
to
[System.Web.Http.HttpPost]
public string MakeCall(CallbackEventModel model)
{
var sinch = SinchFactory.CreateCallbackResponseFactory(Locale.EnUs);
var reader = sinch.CreateEventReader();
var evt = reader.ReadModel(model);
var builder = sinch.CreateIceSvamletBuilder();
SvamletModel svaml = builder.Hangup().Model;
string json = JsonConvert.SerializeObject(svaml, Formatting.Indented);
return json;
}
来源:https://stackoverflow.com/questions/60978486/sinch-callback-api-hangup-in-ice-event