Giter Club home page Giter Club logo

Comments (16)

rraptorr avatar rraptorr commented on July 30, 2024

Would you consider providing some more information about your problem? Because right now there is little anyone can help as there are no details of the problem. How does your setup look like? Have you read "Hints on Usage" section in the README and followed the instructions? What do you mean by "ejabberd+openfire"? You cannot use both at the same time.

from jsjac.

pokal4u avatar pokal4u commented on July 30, 2024

HI,

Mycode is:

<title>JSJaC Simple Client</title>
<script type="text/javascript" src="../jsjac.js"></script>
<!-- comment in above and uncomment below if you want to modify/hack
     on jsjac -->
<!--script type="text/javascript" src="../src/JSJaC.js"></script-->

<!-- if you want to enable debugging uncomment line below
     debugger available at 
      http://svn.stefan-strigler.de/JSDebugger/trunk -->
<!--script type="text/javascript" src="Debugger.js"></script-->

<script language="JavaScript" type="text/javascript">

// <![CDATA[
function handleIQ(aIQ) {
document.getElementById('iResp').innerHTML +=
"

IN (raw): " +aIQ.xml().htmlEnc() + '
';
document.getElementById('iResp').lastChild.scrollIntoView();
con.send(aIQ.errorReply(ERR_FEATURE_NOT_IMPLEMENTED));
}

function handleMessage(aJSJaCPacket) {
var html = '';
html += '

Received Message from '+aJSJaCPacket.getFromJID()+':
';
html += aJSJaCPacket.getBody().htmlEnc() + '
';
document.getElementById('iResp').innerHTML += html;
document.getElementById('iResp').lastChild.scrollIntoView();
}

function handlePresence(aJSJaCPacket) {
var html = '

';
if (!aJSJaCPacket.getType() && !aJSJaCPacket.getShow())
html += ''+aJSJaCPacket.getFromJID()+' has become available.';
else {
html += ''+aJSJaCPacket.getFromJID()+' has set his presence to ';
if (aJSJaCPacket.getType())
html += aJSJaCPacket.getType() + '.
';
else
html += aJSJaCPacket.getShow() + '.';
if (aJSJaCPacket.getStatus())
html += ' ('+aJSJaCPacket.getStatus().htmlEnc()+')';
}
html += '
';

document.getElementById('iResp').innerHTML += html;
document.getElementById('iResp').lastChild.scrollIntoView();
}

function handleError(e) {
document.getElementById('err').innerHTML = "An error occured:
"+
("Code: "+e.getAttribute('code')+"\nType: "+e.getAttribute('type')+
"\nCondition: "+e.firstChild.nodeName).htmlEnc();
document.getElementById('login_pane').style.display = '';
document.getElementById('sendmsg_pane').style.display = 'none';

if (con.connected())
con.disconnect();
}

function handleStatusChanged(status) {
oDbg.log("status changed: "+status);
}

function handleConnected() {
document.getElementById('login_pane').style.display = 'none';
document.getElementById('sendmsg_pane').style.display = '';
document.getElementById('err').innerHTML = '';

con.send(new JSJaCPresence());
}

function handleDisconnected() {
document.getElementById('login_pane').style.display = '';
document.getElementById('sendmsg_pane').style.display = 'none';
}

function handleIqVersion(iq) {
con.send(iq.reply([
iq.buildNode('name', 'jsjac simpleclient'),
iq.buildNode('version', JSJaC.Version),
iq.buildNode('os', navigator.userAgent)
]));
return true;
}

function handleIqTime(iq) {
var now = new Date();
con.send(iq.reply([iq.buildNode('display',
now.toLocaleString()),
iq.buildNode('utc',
now.jabberDate()),
iq.buildNode('tz',
now.toLocaleString().substring(now.toLocaleString().lastIndexOf(' ')+1))
]));
return true;
}

function doLogin(aForm) {
document.getElementById('err').innerHTML = ''; // reset

try {
// setup args for contructor
oArgs = new Object();
oArgs.httpbase = aForm.http_base.value;
oArgs.timerval = 2000;

if (typeof(oDbg) != 'undefined')
  oArgs.oDbg = oDbg;

if (aForm.backend[0].checked)
  con = new JSJaCHttpBindingConnection(oArgs);
else
  con = new JSJaCHttpPollingConnection(oArgs);

setupCon(con);

// setup args for connect method
oArgs = new Object();
oArgs.domain = aForm.server.value;
oArgs.username = aForm.username.value;
oArgs.resource = 'jsjac_simpleclient';
oArgs.pass = aForm.password.value;
oArgs.register = aForm.register.checked;
oArgs.authtype = 'nonsasl';
con.connect(oArgs);

} catch (e) {
document.getElementById('err').innerHTML = e.toString();
} finally {
return false;
}
}

function setupCon(con) {
con.registerHandler('message',handleMessage);
con.registerHandler('presence',handlePresence);
con.registerHandler('iq',handleIQ);
con.registerHandler('onconnect',handleConnected);
con.registerHandler('onerror',handleError);
con.registerHandler('status_changed',handleStatusChanged);
con.registerHandler('ondisconnect',handleDisconnected);

con.registerIQGet('query', NS_VERSION, handleIqVersion);
con.registerIQGet('query', NS_TIME, handleIqTime);

}

function sendMsg(aForm) {
if (aForm.msg.value == '' || aForm.sendTo.value == '')
return false;

if (aForm.sendTo.value.indexOf('@') == -1)
aForm.sendTo.value += '@' + con.domain;

try {
var aMsg = new JSJaCMessage();
aMsg.setTo(new JSJaCJID(aForm.sendTo.value));
aMsg.setBody(aForm.msg.value);
con.send(aMsg);

aForm.msg.value = '';

return false;

} catch (e) {
html = "<div class='msg error''>Error: "+e.message+"";
document.getElementById('iResp').innerHTML += html;
document.getElementById('iResp').lastChild.scrollIntoView();
return false;
}
}

function quit() {
var p = new JSJaCPresence();
p.setType("unavailable");
con.send(p);
con.disconnect();

document.getElementById('login_pane').style.display = '';
document.getElementById('sendmsg_pane').style.display = 'none';
}

function init() {
if (typeof(Debugger) == 'function') {
oDbg = new Debugger(2,'simpleclient');
oDbg.start();
} else {
// if you're using firebug or safari, use this for debugging
//oDbg = new JSJaCConsoleLogger(2);
// comment in above and remove comments below if you don't need debugging
oDbg = function() {};
oDbg.log = function() {};
}

try { // try to resume a session
if (JSJaCCookie.read('btype').getValue() == 'binding')
con = new JSJaCHttpBindingConnection({'oDbg':oDbg});
else
con = new JSJaCHttpPollingConnection({'oDbg':oDbg});

setupCon(con);

if (con.resume()) {

  document.getElementById('login_pane').style.display = 'none';
  document.getElementById('sendmsg_pane').style.display = '';
  document.getElementById('err').innerHTML = '';

}

} catch (e) {} // reading cookie failed - never mind

}
onload = init;

onerror = function(e) {
document.getElementById('err').innerHTML = e;

document.getElementById('login_pane').style.display = '';
document.getElementById('sendmsg_pane').style.display = 'none';

if (con && con.connected())
con.disconnect();
return false;
};

onunload = function() {
if (typeof con != 'undefined' && con && con.connected()) {
// save backend type
if (con._hold) // must be binding
(new JSJaCCookie('btype','binding')).write();
else
(new JSJaCCookie('btype','polling')).write();
if (con.suspend) {
con.suspend();
}
}
};

// ]]>
</script>

Login

Backend Type HTTP Binding
HTTP Polling
HTTP Base

Jabber Server
Username
Password
Register new account
 

Incoming:

Send Message

To:
<textarea name="msg" id='msgArea' rows="3" cols="80" tabindex="2"></textarea>
\*

and out put:

jajac

from jsjac.

rraptorr avatar rraptorr commented on July 30, 2024

You still have not provided details of your server setup. Also you didn't answer my questions. Unfortunately I cannot help without you providing those answers.

And please use code formatting (or gist) as the above is completely unreadable.

from jsjac.

rraptorr avatar rraptorr commented on July 30, 2024

Also, you can try to uncomment the JSJaCConsoleLogger (set the log level to 4) and see what is shown in the JavaScript console.

from jsjac.

pokal4u avatar pokal4u commented on July 30, 2024

Hi,

I am using ejabbered server

I followed the same process

added /http-bind/ redirect in .htaccess

uncommented JSJaCConsoleLogger and set to 4 does't show any errors

can i send ejabbered details?

please help me

Thanks
Srinivas

from jsjac.

rraptorr avatar rraptorr commented on July 30, 2024

If you have enabled JSJaCConsoleLogger then you have a lot of debugging information in JavaScript console (not in the browser window).
Have you verified that your ejabberd server works with normal XMPP client? Have you verified that your /http-bind/ redirect is working properly?

from jsjac.

pokal4u avatar pokal4u commented on July 30, 2024

Hi,

ejabbered server worked fine. I checked with strophe.js and candy.js and sent messages successfully (but i am facing anonymous user login connection failed).

I am checked debugging information in javascript console (please find attached image)
jajac1

Please help me

Thanks

from jsjac.

rraptorr avatar rraptorr commented on July 30, 2024

It seems that you have not enabled the debugger as otherwise you would have a lot of log entries there. Please make sure that you have enabled it correctly (you have to uncomment the JSJaCConsoleLogger line but you also, obviously, have to comment out the default empty function assigned to oDbg object).

from jsjac.

pokal4u avatar pokal4u commented on July 30, 2024

Hi,
ok now enabled the debugger

and how can i start bosh module?

Please check attached image
jajac4

and comment below line
//oArgs.authtype = 'nonsasl';

getting below error

jajac3

Thanks

from jsjac.

rraptorr avatar rraptorr commented on July 30, 2024

As you can clearly see in the debug log, you have not enabled BOSH module on ejabberd (message "BOSH module not started"). Start by enabling it:)

from jsjac.

pokal4u avatar pokal4u commented on July 30, 2024

Hi,

Thanks for reply

I started bosh module.
now getting below error

Please check attached image

jajac4

and comment below line
//oArgs.authtype = 'nonsasl';

getting below error

jajac3

Please help me

Thanks

from jsjac.

rraptorr avatar rraptorr commented on July 30, 2024

You are using invalid username "[email protected]". This is the whole JID, username is only the part before @, so use only "admin" as username.

from jsjac.

pokal4u avatar pokal4u commented on July 30, 2024

H,

I am using username as 'admin' but getting same error below

jajac5

Please help me
Thanks

from jsjac.

rraptorr avatar rraptorr commented on July 30, 2024

Are you sure you have set up [email protected] account properly? The server also gives such response for non existing accounts.

from jsjac.

pokal4u avatar pokal4u commented on July 30, 2024

Hi,

Now working fine, but not supported multiple tabs

I am used simpleclient.html uses resource "jsjac_simpleclient".
and simpleclient1.html uses resource "jsjac_simpleclient1".

run two files in two tabs

getting below error in on tab and another tab connected successfully
An error occured:
Code: 401
Type: auth
Condition: not-authorized

Please help

Thanks

from jsjac.

rraptorr avatar rraptorr commented on July 30, 2024

Please do not post the same problem in multiple issues. It really doesn't help anyone trying to make sense from what you write.

Also, it is considered good practice to inform other people that your problem was solved and to close the issue.

from jsjac.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.