WebAPI/WebSTK: Difference between revisions

Line 494: Line 494:
   var details = command.cmdDetails;
   var details = command.cmdDetails;
   switch (details.typeOfCommand) {
   switch (details.typeOfCommand) {
     case MozStkProactiveCommand.STK_SET_UP_MENU:
     case MozStkProactiveCommand.SET_UP_MENU:
        var menu = command.param.menu;
      var menu = command.param.menu;
        // create a Menu-like UI according to 'menu'
      // create a Menu-like UI according to 'menu'
     break;
     break;
   }
   }
Line 508: Line 508:
// and assume it's a SET_UP_MENU command.
// and assume it's a SET_UP_MENU command.
var response = new MozStkResponse(command);
var response = new MozStkResponse(command);
response.resultCode = MozStkResultCode.STK_RESULT_OK;
response.resultCode = MozStkResultCode.RESULT_OK;
// 'id' is got from the chosen item identifier (menu.item[].identifier)
// 'id' is got from the chosen item identifier (menu.item[].identifier)
response.menuSelection(id);
response.menuSelection = id;
mobileConnection.sendStkResponse(response);
mobileConnection.sendStkResponse(response);
</pre>
== Get Input ==
<pre>
mobileConnection.onstkcommand = function (command) {
  var details = command.cmdDetails;
  switch (details.typeOfCommand) {
    case MozStkProactiveCommand.GET_INPUT:
      var input = command.param.input;
      // create a TextInput-like UI according to 'input'
    break;
  }
};
// onTextInput is the callback when user inputs complete.
function onTextInput(input) {
  var response = new MozStkResponse(command);
  response.resultCode = MozStkResultCode.RESULT_OK;
  response.input = input;
  mobileConnection.sendStkResponse(response);
}
</pre>
== Set Up Call ==
<pre>
mobileConnection.onstkcommand = function (command) {
  var details = command.cmdDetails;
  switch (details.typeOfCommand) {
    case MozStkProactiveCommand.SET_UP_CALL:
      var setup = command.param.setup;
      // create a Text Message UI to ask user confirmation
      // for make the MO call.
    break;
  }
};
// onUserConfirm is the callback when user confirms the call.
function onUserConfirm(confirm) {
  var response = new MozStkResponse(command);
  response.resultCode = MozStkResultCode.RESULT_OK;
  response.confirmation = confirm;
  mobileConnection.sendStkResponse(response);
}
</pre>
</pre>


Confirmed users
266

edits