Smack beans cfmx

If you can get the packet listener to work email me but

here is the final code for CFMX!

This creates the object one time and keeps the connection

with zeus.jabber.org:5222

<cfif isdefined(“session.XMPPConnection”)>

<cfif session.XMPPConnection.isConnected()>

<cfset session.XMPPConnection = createObject(“java”, “org.jivesoftware.smack.XMPPConnection”).init(“jabber.org”)>

<cfset session.XMPPConnection.login(“danpxxx”, “ziloxxx”)>

<cfset session.XMPPConnection = createObject(“java”, “org.jivesoftware.smack.XMPPConnection”).init(“jabber.org”)>

<cfset session.XMPPConnection.login(“danpxxx”, “ziloxxxx”)>

This does not create the chat side just the connection object. Check NETSTAT in DOS

You can turn on the dedugger like so

<cfif isdefined(“form.client”)>

<cfset session.chat = session.XMPPConnection.createChat("#form.client#")>

<cfif isdefined(“form.message”)>

<cfset chat.sendMessage("#form.message#")>

I could not get this to work

<cfset session.XMPPConnection.addMessageListener(org_jivesoftware_smack_PacketListener , org_jivesoftware_smack_filter_PacketFilter)>

It returned null or empty string which might be the

right result.

Message was edited by: danp5648

You have to use a real account and not “mtucker” and “password”.

Regards,

Matt

just

<cfset session.socket = createObject(“java”, “java.net.Socket”).init(“zeus.jabber.org”, “5222”)/>

I have no idea how to then use this socket connection with SMACK.

Message was edited by: danp5648

Heh. I guess I should have taken a step back and answered the question more generally. Smack is for communicating with XMPP servers, which has nothing to do with these forums. Your code snippet tried to connect to the xmpp server at jabber.org and then login using an account “mtucker” with the password “password”. That’'s a bogus account, so the server told you that you were unauthorized.

You need to try logging into an actual account. Another option is to create an account on an a server with open registration. The AccountManager class will allow you to do this. See the Javadocs for more info:

http://www.jivesoftware.com/xmpp/smack/api/

Regards,

Matt

Hi matt,

I have read all the other posts regarding Smack and CFMX but it does not seem to me like anyone has done it. One user “romen” suggested a Flash user interface / Remoting / Coldfusion solution. Did he get it to work?

Iain Shigeoka wrote:

“Definitely would be cool. I’'m not aware of anyone doing it yet but it would probably be easy using the Smack library.”

Is the “Smack library” just that jar file and should I include both jar files in the lib directory?

It would be great to create a server using coldfusion java

object creation. Are you implying that this can be done?

Is the next Coldfusion upgrade including the Smack library in its next upcoming release? Thanks Dan

Message was edited by: danp5648

I have read all the other posts regarding Smack and

CFMX but it does not seem to me like anyone has done

it. One user “romen” suggested a Flash user interface

/ Remoting / Coldfusion solution. Did he get it to

work?

No, I’'m not aware of anyone writing an XMPP client for CFMX using Smack. What are you trying to accomplish, btw? A full IM system through a web interface? Something simpler?

Is the “Smack library” just that jar file and should

I include both jar files in the lib directory?

Yes, it’‘s smack.jar and smackx.jar and that’‘s it. I’'m not familiar with CFMX, but the lib directory sounds correct.

It would be great to create a server using coldfusion

java

object creation. Are you implying that this can be

done?

It’‘s not that you’‘re creating a server. Smack is a client library – it lets you connect to a server and act as a client by logging in, doing operations on a roster (buddy list), sending messages, etc. If you want to run a server, you’‘d need to do that separately. Again, I’‘m not sure what you’'re trying to accomplish, so knowing that might help us give advice.

Is the next Coldfusion upgrade including the Smack

library in its next upcoming release? Thanks Dan

Heh, I have no idea. Certainly nobody has contacted us about it, although they could do so if they liked since it is Open Source.

Regards,

Matt

Matt,

ok I dropped the other jar file in the lib folder and I can access the class files just fine. I don’'t think the other CFMX people were able to do this.

Typing in “CFMX” into the search box returns two posts. One was my post and the other was Roman post.

Roman goes into depth about a CFMX client

http://www.jivesoftware.com/jive/thread.jspa?forumID=39&threadID=8394&messageID= 61588#61588

but all the CFMX posters grow cold and stop posting after

two or three posts. I guess they just moved on.

I emailed a few people and got this reply.

Joshua Olson writes:

“I never did get the threads to work. Sorry.”

“THREADS”?

I found out that Coldfusion is what java should be. The tags are just masks for java. They mixed easy-to-use tags and then connected those tags to java objects. So you get the power java hidding in the background, while programmers interact with html style tags. Most CF people stay with the tags, but I like to cause trouble and started playing with the java side, which is forbidden. All my post are located at http://groups.yahoo.com/group/coldfusion-howto/

search for “dan plesse”. You can read at least one angry poster.

Anyway I would like make a IM chat system using CFMX and

Flash remoting. Do you think this can be done. Dan

It certainly can be done. I think the trick is going to be in exposing the smack library as CFML tags properly. One thing that makes XMPP (the jabber protocol) different from other IM protocols is that clients maintain a persistent connection to the server for the length of the session. This means once you create a smack XMPPConnection, you need to store it in it’'s open state, and re-use it for as long as the user is ‘‘online’’.

In Jive’'s jsp driven webclient using smack, the XMPPConnection is stored in the session object so that it stays around during the length of the web session and is reused everytime that some user hits the page. I suspect something similar is available in CFMX and you can store the XMPPConnection object there.

Smack actually handles the threading issues behind the scenes so in the most straightforward scenario, you should not need to worry about threading. One of the best exercises to getting Smack working in CFMX would be to take one of the example client Java code snippets that have been posted to the forums to connect to a server, and send a message. You can verify this works by logging into the same server with a regular XMPP client and seeing if you receive the message.

The exercise then is to simply port the Java code to CFMX calls so you replicate the usage of Smack to do the same thing. Then verify it works. The user ‘‘Gato’’ has posted several really nice, short java code snippets that will get you started so just do a search on him.

-iain

iain,

“take one of the example client Java code snippets that have been posted to the forums to connect to a server”

The code snippet I posted works, but I can’‘t seem find an XMPP server to test on or get valid user id / password for jabber.org and I can’'t seem to find an windows based XMPP server to install.

I guess I’'ll keep searching for Gato posts.

“You can verify this works by logging into the same server with a regular XMPP client and seeing if you receive the message.”

So send a message to yourself and then look for it.

I would like to build the server as well in coldfusion too starting I guess with the “Accountmanager.class” Would that work?? Dan

hey Dan,

I think you pinged me on my blog about this, so I wrote up a quick ColdFusion, Jabber and Smack tutorial, which you can read about here:

http://cephas.net/blog/2004/01/07/instant_messenging_with_coldfusion_jabber_and_ smack.html

(watch link wrap)

Bottom line: smack makes it extremely easy to work with Jabber and ColdFusion makes it extremely quick to script a web-based IM solution.

AJ

THANK YOU!

So far I installed a client exodus_0.8.6.0.exe on a windows machine. I installed it and after a bunch of runtime 217 00BC753D errors it installed and I logged on to jabber.org. It allowed me to add a user and a password and also it gave me an email address I think (danp5648@jabber.org/EXODUS) and got a default message from them. So now I am good to go to the next step.

exodus_0.8.6.0.exe

http://www.jabberstudio.org/projects/exodus/releases/view.php?id=238

I also found another jar file openim-users-manager-ldap-impl-1.1.jar

Maybe I can drop that file into CFMX lib and get the server side to work next.

Message was edited by: danp5648

The code snippet I posted works, but I can’'t seem

find an XMPP server to test on or get valid user id /

password for jabber.org and I can’'t seem to find an

windows based XMPP server to install.

This one is extremely easy to setup and use:

Thanks I got that part resolved and I even got

the words “Howdy” to show up on an Exodus client however I don’'t like the html interface and I would like to have flash with remoting to handle the front end while CFMX still handling the backend. Has anyone done that yet??? Thanks again, Dan.

The last part

<cfset XMPPConnection = createObject(“java”, “org.jivesoftware.smack.XMPPConnection”).init(“jabber.org”)>

<cfset XMPPConnection.login(“putuser”, “putpassword”)>

<cfset chat = XMPPConnection.createChat("danp5648@jabber.org/Exodus")>

<cfset chat.sendMessage(“Howdy!”)>

Looks like I have make Coldfusion MX Smack beans because

of addListener (packet, filter) can not be done. They should have CF smack beans by default because CF needs IM.

Message was edited by: danp5648

How do you use Smack with CFMX to register an ICQ or MSN transport and to make use of thier SMS gateway? By the way, I make use of the post on this http://cephas.net/blog/2004/01/07/instant_messenging_with_coldfusion_jabber_and_ smack.html

to post IM to user from CFMX and it works great!

My client works better then his does, much better. And

I adjusted the code so anyone in the world can send jabber messages to any jabber client. Only part I have to work out is a way to read incoming messages and save them

to a database or make use of them. His code has the same darn problem as my code. It recieves messages but only the message which was just sent. Why does it do that? What about a message coming from a client and not just an echo. The other problems with his code is the refreshing and each time the browser refreshes it creates another port address and it does not keep a connection to zeus.jabber.org:5222 which my code does. I have two socket connections to zeus. I don’‘t know why his code never connects to zeus and my does and I don’‘t know if that’'s a good thing. My Exodus client connects to zeus.

I tried to create a serversocket with an accept() method

and seems to just stay in a loop and not do any of the other tasks. That is why I think I need a new thread. Should I connect a socket to zeus? What things are flying at me from the Exodus client or from zeus? What do I need to do to catch them? -dan I know I can create a DB socket in JDBC and keep both sockets open but how do I cross streams (pass info) ?