SIPml5 one sided voice - sip

Below is the code of my dialer. I can register and connect calls successfully with the below code. But, after call is connected only the other end (non sipml5) can hear voice. But, the sipml5 side can not hear anything.However, I could connect and pass voice using the sipml5 client from sipml5 website(sipml5.org/call.htm). I must be doing something wrong, but cant figure out what.
<script src="api/SIPml-api.js" type="text/javascript"> </script>
<script type="text/javascript">
var readyCallback = function(e){
createSipStack(); // see next section
};
var errorCallback = function(e){
onsole.error('Failed to initialize the engine: ' + e.message);
}
SIPml.init(readyCallback, errorCallback);
var sipStack;
var callSession;
function eventsListener(e){
console.info('Change of status|Server response: '+e.type+':'+e.message+':'+e.
session+':'+e.description);
if(e.type == 'started'){
login();
}
else if(e.type == 'i_new_message'){ // incoming new SIP MESSAGE (SMS-like)
acceptMessage(e);
}
else if(e.type == 'i_new_call'){ // incoming audio/video call
if(confirm("Incomming Call Request! Do you accept?")){
acceptCall(e);
}else{
e.newSession.reject()
}
}
else if(e.type == 'connected'){
if(e.session == registerSession){
setStatus(e.type,'Registered...');
}else{
setStatus(e.type,e.description);
}
}
else if(e.type == 'i_ao_request' && e.description == 'Ringing' ){
document.getElementById('call').value = 'End Call';
setStatus(e.type,e.description);
}
else if(e.type == 'terminated' || e.type == 'terminating'){
if(e.session == registerSession){
setStatus('Unable to Register');
}else{
setStatus(e.type,e.description);
}
}
}
function createSipStack(){
sipStack = new SIPml.Stack({
realm: 'foo.bar.com',
impi: 'usertest',
impu: 'sip:usertest#foo.bar.com',
password: '1234',
display_name: 'alice',
websocket_proxy_url: 'ws://11.11.11.0:8080',
enable_rtcweb_breaker: false,
events_listener: { events: '*', listener: eventsListener },
sip_headers: [ // optional
{ name: 'User-Agent', value: 'IM-client/OMA1.0 sipML5-v1.0.0.0' },
{ name: 'Organization', value: 'SuperCops.us' }
]
}
);
}
sipStack.start();
function login(){
registerSession = sipStack.newSession('register', {
events_listener: { events: '*', listener: eventsListener } // optional: '*' means all events
});
registerSession.register();
}
function makeCall(){
var number = document.getElementById('number').value;
if(number == ''){
alert('No number entered');
}
else if(document.getElementById('call').value == 'End Call'){
callSession.hangup();
}else{
setStatus('Trying','Trying to call:'+numberFilter(number));
callSession = sipStack.newSession('call-audio',{
events_listener: { events: '*', listener: eventsListener }
});
callSession.call(numberFilter(number));
}
}
function acceptCall(event){
callSession = event.newSession;
/*('accept',{
events_listener: { events: '*', listener: eventsListener }
});*/
callSession.accept();
eventsListener(callSession);
setStatus('connected','In Call');
}
function setStatus(type,status){
document.getElementById('status').innerHTML = status;
if(type == 'terminated' || type == 'terminating'){
document.getElementById('call').value = 'Call';
}else if(status == 'Ringing' || status == 'Ringing' || status == 'In Call' || type == 'Trying'){
document.getElementById('call').value = 'End Call';
}
}
function numberFilter(number){
return number;
}

Related

My dispatch method not working after dispatching in just iPhone Chrome (IOS 15.7.2)

I am working in Vue Js with Laravel. But specifically in iPhone Chrome my dispatch method is not working after dispatching. Please if anyone finds this type of issue in iPhone devices. Please provide any relevant solution.
Here the API Call code.
ProviderProfileService.addAddress(this.$apiUrl, this.address).then(
(response) => {
let result = response.data.createServiceLocation;
if (result.status == "success") {
let steps_status = JSON.parse(
result.service_location.user.providerProfileItems.profile_steps_status
);
if (steps_status.addrestime == true) {
alert(1);
this.$store
.dispatch("update_provider_profile_status", {
providerProfileStatus: steps_status,
})
.then((res) => {
alert(2);
this.$store.dispatch("update_progress_bar").then((res1) => {
if (response.data.createServiceLocation.status == "error") {
alert(0);
self.updateAddress();
} else {
this.$router.push(
"/provider-profile/language/" + this.userConfig.unique_identifier
);
alert(3);
// this.$router.push({
// name: "Language",
// params: { id: this.userConfig.unique_identifier },
// });
alert(4);
// window.location.href =
// "https://19b0-2404-3100-1c81-8081-e0bc-c658-121c-836b.ngrok.io/provider-profile/language/" +
// this.userConfig.unique_identifier;
this.scrollToTop();
alert(5);
}
});
});
}
}
},
(error) => {
self.content =
(error.response && error.response.data) || error.message || error.toString();
}
);
Here is the dispatch method code.
state.providerProfileStatus.basicinfo = (payload.basicinfo)?true:false;
state.providerProfileStatus.rates = (payload.rates)?true:false;
state.providerProfileStatus.services = (payload.services)?true:false;
state.providerProfileStatus.addrestime = (payload.addrestime)?true:false;
state.providerProfileStatus.availability = (payload.availability)?true:false;
state.providerProfileStatus.integrations = (payload.integrations)?true:false;
state.providerProfileStatus.certifications = (payload.certifications)?true:false;
state.providerProfileStatus.payment_settings = (payload.payment_settings)?true:false;
state.providerProfileStatus.documents_and_vaccination = (payload.documents_and_vaccination)?true:false;
state.providerProfileStatus.language_and_introduction = (payload.language_and_introduction)?true:false;

Receive 'subscribe' presences with Strophe.js Roster plugin and Ejabberd

I'm using the Strophe.js Roster plugin with Ejabberd as XMPP Server. When I use Adium or some other XMPP Clients I can add some other accounts in my Roster. When I send an invitation, the other account receives presence with type=='subscribe'.
Wit Strophe.js Roster, I never receive any presence with type == 'subscribe'!
I tried everything...I added some handlers...I "filtered" and ...
Here is my code :
HTML includes
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js'></script>
<script src='../strophe.js'></script>
<script src="../strophe.muc.js"></script>
<script src="../strophe.register.js"></script>
<script src="../strophe.roster.js"></script>
<script src='my-code.js'></script>
my-code.js
var jid;
$(document).ready(function () {
connection = new Strophe.Connection(BOSH_SERVICE, {'keepalive': true});
//connection.rawInput = rawInput;
//connection.rawOutput = rawOutput;
connection.addHandler(onPresence, null, 'presence', null, null, null);
connection.roster.registerRequestCallback(onRequest);
// Manage connection
try {
$('#connect').get(0).value = 'disconnect';
connection.restore(null, onRegister);
} catch(e) {
if (e.name !== "StropheSessionError") { throw(e); }
$('#connect').get(0).value = 'connect';
}
$('#connect').bind('click', function () {
var button = $('#connect').get(0);
if (button.value == 'connect') {
button.value = 'disconnect';
jid = $('#jid').get(0).value;
connection.connect(jid, $('#pass').get(0).value, onConnect, 10);
} else {
button.value = 'connect';
connection.disconnect();
}
});
});
function onPresence(stanza)
{
log("PRESENCE");
console.log(stanza);
return true;
}
function onRequest(req) {
console.log("Request");
console.log(req);
return true;
}
Am I missing something?
I solved my problem!
We must send a presence when the connection's status is
Strophe.Status.CONNECTING
function onConnect(status)
{
if (status == Strophe.Status.CONNECTING) {
log('Strophe is connecting.');
} else if (status == Strophe.Status.CONNFAIL) {
log('Strophe failed to connect.');
} else if (status == Strophe.Status.DISCONNECTING) {
log('Strophe is disconnecting.');
} else if (status == Strophe.Status.DISCONNECTED) {
log('Strophe is disconnected.');
} else if (status == Strophe.Status.CONNECTED) {
log('Strophe is connected.');
// Send a presence to the server
connection.send($pres().tree());
}
}

form validation on submit

I am facing problem in form validation. Following is my jQuery validation code.
kindly help me how this validation is working on submit button.
<script type="text/javascript">
$(document).ready(function() {
$(".col a").click(function() {
$(".col a").removeClass("active");
$(this).addClass("active");
});
});
jQuery(document).ready(function() {
jQuery(".expContent").hide();
//toggle the componenet with class msg_body
jQuery(".expHeading").click(function() {
jQuery(this).next(".expContent").slideToggle(500);
});
});
$(document).ready(function() {
// Vertical
$("#vertical").on("blur", function(e) {
if ($("#vertical").val().length < 2) {
alert("vertical", "Vertical is Mandatory");
} else {
hideMsg("vertical");
}
});
// Name
$("#name").on("blur", function(e) {
if ($("#name").val().length < 2) {
alert("Name is Mandatory");
} else {
hideMsg("name");
}
});
function IsEmail(email) {
var filter = /^[\w-\.]+#([\w-]+\.)+[\w-]{2,4}$/;
if (filter.test(email)) {
return true;
} else {
return false;
}
}
$("#email").on("blur", function(e) {
if ($("#email").val().length == 0) {
//alert("Please submit a Valid Email Id");
}
if (IsEmail($("#email").val())) {
hideMsg("email");
} else {
alert("Please submit a Valid Email Id");
}
});
// Mobile No
$("#enqMobileNo").on("blur", function(e) {
if ($("#enqCountryResidence").val() == "in") {
if ($("#enqMobileNo").val().length == 10) {
hideMsg("enqMobileNo");
} else {
alert('Please Enter 10 Digit Mobile No. Only like 9812345678. Without Area or Country Code i.e "0" or "+91"');
}
} else {
if ($("#enqMobileNo").val().length 1) {
hideMsg("enqMobileNo");
} else {
alert("Please Enter Mobile No. Only. Without Area or Country Code");
}
}
});
$("#enqMobileNo").on('keyup', function() {
if ($("#enqMobileNo").val() == "0") {
$("#enqMobileNo").val("");
}
if ($("#enqCountryResidence").val() == "in") {
limitText(this, 10);
if ($("#enqMobileNo").val().length == 10) {
hideMsg("enqMobileNo");
}
} else {
//inlineMsg
("enqMobileNo", "Please Enter Mobile No. Only<br /Without Area or Country Code");
}
});
// Gender
$("#gender").on("blur", function(e) {
if ($("#gender").val() == "") {
alert('Please select Gender', 2);
} else {
hideMsg("gender");
}
});
// Age
$("#age").on("blur", function(e) {
if ($("#age").val() == "") {
alert('Please select Age', 2);
} else {
hideMsg("age");
}
});
// City
$("#enqCity").on("blur", function(e) {
if ($("#enqCity").val() == "") {
alert('Current Location City Name is Mandatory', 2);
} else {
hideMsg("enqCity");
}
});
// Course
$("#enqSection").on("blur", function(e) {
if ($("#enqSection").val() == "") {
alert('Please Select Course', 2);
} else {
hideMsg("enqSection");
}
});
// Spl
$("#enqSpeciality").on("blur", function(e) {
if ($("#enqSpeciality").val() == "") {
alert('Please Select Speciality', 2);
} else {
hideMsg("enqSpeciality");
}
});
// Level
$("#enqLevel").on("blur", function(e) {
if ($("#enqLevel").val() == "") {
alert('Please Select Level', 2);
} else {
hideMsg("enqLevel");
}
});
function limitText(field, maxChar) {
var ref = $(field),
val = ref.val();
if (val.length = maxChar) {
ref.val(function() {
console.log(val.substr(0, maxChar))
return val.substr(0, maxChar);
});
}
}
});
</script>
I think it is better to use jQuery form validation plugin. It is very easy to use.You can get step by step help with examples on this site

Jquery Notification on Ajax POST Success

I have an issue with a some of the jQuery notifications I have created to trigger based on information echo'd from a PHP file after a user submits a sign up HTML form via AJAX. The notifications for errors work, but not for a successful post to the database. I know that the success notification should show because the data is validated and written to the database and AJAX post is successful. However the success notification does not want to work. What could be the reason for this technicality?
I have the following set up:
signup.html (contains the following ajax within the page*):
function registerUser(formKey) {
$.ajax({
type:"POST",
url:"engine/new_user.php",
data: $("#"+formKey).serialize(),
cache:false,
success: function(data) {
if(data == -3){
$("html, body").animate({ scrollTop: 0 }, 600);
$("#user-exists-notification").fadeIn(1000);
}
if(data == -4){
$("#account-created").fadeIn(1000);
}
if(data == -1){
$("html, body").animate({ scrollTop: 0 }, 600);
$("#fields-complete-notification").delay(1000).fadeIn(1000);
}
if(data == -2){
$("html, body").animate({ scrollTop: 0 }, 600);
$("#pw-confirm-notification").delay(1000).fadeIn(1000);
}
},
error: function(data) {
}
});
}
new_user.php
require("register-classes.php");
$register=new Register($_POST['fname'], $_POST['lname'], $_POST['email'], $_POST['sex'], $_POST['birthdate'], $_POST['phone'], $_POST['country'], $_POST['alias'], $_POST['handle'], $_POST["password"], $_POST["cpassword"], $_POST['network']);
if($register->checkFields()== false){
echo -1;
} else if($register->confirmPasswords()== false){
echo -2;
}else if($register->registerUser()!=false){
echo -4;
} else if($register->registerUser()==false){
echo -3;
}
and register-classes.php (which contains classes for processing sign up form)
class Register {
public function __construct($fname, $lname, $mail, $sex,
$birthday, $phonenumber, $regCountry, $alias, $username,
$password, $conf_password, $network_site) {
//Copy Constructor
$this->site=$network_site;
$this->firstname=$fname;
$this->lastname=$lname;
$this->email=$mail;
$this->sex=$sex;
$this->birthdate=$birthday;
$this->phone=$phonenumber;
$this->country=$regCountry;
$this->displayname=$alias;
$this->handle=$username;
$this->salt="a2cflux9e8g7ds6ggty589498j8jko007876j89j8j7";
$this->password=crypt($this->salt.$password);
$this->joindate=date("Y-m-d H:i:s");
$this->confirm_password1=$password;
$this->confirm_password2=$conf_password;
}
public function registerUser(){
$database=new Database();
$database->getConnection();
$database->startConnection();
//Check database to insure user and email address is not already in the system.
$checkUsers= mysql_query("SELECT network_users.network_id
FROM network_users, network_profile
WHERE network_users.handle = '$this->handle'
OR network_profile.email = '$this->email'");
$numRecords= mysql_num_rows($checkUsers);
if($numRecords == 0){
$addUser= mysql_query("INSERT INTO network_users(handle, password, date_created, parent_network, site_created, active, account_type, del)
values('$this->handle', '$this->password', '$this->joindate',' fenetwork', 'network', 'active', 'standard', 'F')") or die(mysql_error());
$networkId=mysql_insert_id();
$addProfile= mysql_query("INSERT INTO network_profile(network_id, first_name, last_name, email, sex, birthdate, phone, country, display_name, del)
values('$networkId', '$this->firstname', '$this->lastname', '$this->email','$this->sex', '$this->birthdate', '$this->phone', '$this->country', '$this->displayname', 'F')") or die(mysql_error());
$this->addUser;
$this->addProfile;
return true;
}
else{
return false;
}
}
public function checkFields(){
if(($this->firstname)!="" && ($this->lastname)!="" && ($this->email)!="" && ($this->sex)!="" &&
($this->birthdate)!="" &&($this->country)!="" && ($this->handle)!="" && ($this->password)!=""){
return true;
} else {
return false;
}
}
public function confirmPasswords(){
if($this->confirm_password1==$this->confirm_password2){
return true;
} else {
return false;
}
}
private $site, $firstname, $lastname, $email,
$sex, $birthdate, $phone, $country, $displayname,
$handle, $password, $salt, $joindate, $confirm_password1, $confirm_password2;
protected $addUser, $addProfile;
}
I found the issue. The issue was due to printf() functions that were apart of a few class members in the database class. They were causing an interruption with the function completing and returning the boolean value true or false in registerUser();
Thank you all for your help and assistance. I would give up a vote up, but I don't have enough reputation points. haha.

XMPP Server - Strophe - I cannot join on the server with my webclient

I have my own xmpp server. At: jenan.cz
Why can not I connect via WebClient?
Error: status CONNFAIL
Application is here: http://jenan.cz/xmpp/
Connection in: http://jenan.cz/xmpp/gab.js
I use the following connection:
$(document).bind('connect', function (ev, data) {
var conn = new Strophe.Connection(
"http://jenan.cz:5280/http-bind/");
conn.connect(data.jid, data.password, function (status) {
if (status === Strophe.Status.CONNECTED) {
$(document).trigger('connected');
} else if (status === Strophe.Status.DISCONNECTED) {
$(document).trigger('disconnected');
} else if (status === Strophe.Status.ERROR) {
alert ('status ERROR');
} else if (status === Strophe.Status.CONNECTING) {
alert ('status CONNECTING');
} else if (status === Strophe.Status.CONNFAIL) {
alert ('status CONNFAIL');
} else if (status === Strophe.Status.AUTHENTICATING) {
alert ('status AUTHENTICATING');
} else if (status === Strophe.Status.AUTHFAIL) {
alert ('status AUTHFAIL');
} else if (status === Strophe.Status.ATTACHED);
alert ('status ATTACHED');
});
Hello.connection = conn;
});
Enable the http-bind module in ejabberd:
{modules,
[
{mod_http_bind, [{max_inactivity, 120}]}
]}.
Change settings for 5280 port:
{5280, ejabberd_http, [
{request_handlers,
[
{["http-bind"], mod_http_bind}
]},
http_bind
web_admin
]
}
Change connection settings:
$(document).bind('connect', function (ev, data) {
var conn = new Strophe.Connection(
'http://jenan.cz:5280/xmpp-http-bind');
conn.connect(data.jid, data.password, function (status) {
if (status === Strophe.Status.CONNECTED) {
$(document).trigger('connected');
} else if (status === Strophe.Status.DISCONNECTED) {
$(document).trigger('disconnected');
}
});
Gab.connection = conn;
});