Comments (16)
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.
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 +=
"
document.getElementById('iResp').lastChild.scrollIntoView();
con.send(aIQ.errorReply(ERR_FEATURE_NOT_IMPLEMENTED));
}
function handleMessage(aJSJaCPacket) {
var html = '';
html += '
';
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
and out put:
from jsjac.
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.
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.
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.
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.
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)
Please help me
Thanks
from jsjac.
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.
Hi,
ok now enabled the debugger
and how can i start bosh module?
and comment below line
//oArgs.authtype = 'nonsasl';
getting below error
Thanks
from jsjac.
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.
Hi,
Thanks for reply
I started bosh module.
now getting below error
Please check attached image
and comment below line
//oArgs.authtype = 'nonsasl';
getting below error
Please help me
Thanks
from jsjac.
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.
H,
I am using username as 'admin' but getting same error below
Please help me
Thanks
from jsjac.
Are you sure you have set up [email protected] account properly? The server also gives such response for non existing accounts.
from jsjac.
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.
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)
- unable to use JsJaC facebook chat client library to my web site ........ i read the read me in the JSJAC but have no idea about how to implement this client library in my website..... and how i can use this link to utilize bosh server "https://jappix.com HOT 4
- Unable to connect to OpenFire HOT 16
- Support method chaining for registerHandler
- get roster presence HOT 2
- jsjac simpleclient android app ( via phonegap ) , doesn't support websocket HOT 5
- XEPs and RFCs support page with version HOT 5
- Handle WebSocket stream termination HOT 1
- ondisconnect not being triggered HOT 1
- Latest release HOT 1
- 503 error HOT 1
- Send 'away' status on before unload event HOT 6
- In firefox doesn`t work adding users to roster. HOT 11
- Websockets Prebound session HOT 2
- Possible to not use cookie? HOT 2
- BOSH over websocket not work. HOT 2
- in Chrom v56.0.2924.87 (正式版本) (32 位) XMLHTTPReaust error HOT 1
- How to implement XEP-0163 PEP function in jsjac? HOT 6
- XMPP Core HOT 2
- Synchronous XMLHttpRequest on the main thread is deprecated
- Support XEP-0184: Message Delivery Receipts HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsjac.