What is strophe and how to use it with JQuery? - javascript

Can somebody explain what strophe is?
I believe it has something to do with XMPP?
How can I incorporate it into a site using Jquery?

Strophe is not a Jabber Client, and its not an XMPP client. Its a library that allows you to easily write either of these. You could (with great difficulty) write a Jabber/XMPP Client from scratch using Javascript or Jquery, but this would be very difficult imagine generating and sending XML like this:
<body xmlns='http://jabber.org/protocol/httpbind' sid='e4fcc09444a61059e88296a106e86e1ff1454f9b' wait='60' requests='2' inactivity='30' maxpause='120' polling='2' ver='1.8' from='localhost' secure='true' authid='1027072784' xmlns:xmpp='urn:xmpp:xbosh' xmlns:stream='http://etherx.jabber.org/streams' xmpp:version='1.0'><stream:features xmlns:stream='http://etherx.jabber.org/streams'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
Strophe is a library of Javascript functions that makes the process of writing an XMPP client easier. It has methods to allow you to connect to a server, to send a message to a user, to add a contact - and it knows about the XML that needs to be sent to the server to carry out these actions. It basically does all the difficult stuff - the XML generating, sending, connecting and communicating stuff for you. Which makes your life a whole lot easier.

Strophe is a XMPP client, written in Javascript. More specifically, it is a Javascript library that lets you write real-time web applications that have full XMPP capabilities. It is "real-time" because is uses a "Comet-like" technique known as "BOSH" http://xmpp.org/extensions/xep-0124.html.
Once you learn the basics of Strophe, using it with jQuery will "just work" as there is no conflicting code, named functions, or dependencies.

The API documentation for the library can be found here -> str<>phe API
It's a javascript library that's separate to jQuery but obviously you can call any javascript library from any other so I don't believe you'll have any requirement for a specific jQuery integration.

Strophe already uses jQuery. In fact, the Strophe builder APIs borrow the $() syntax from jQuery. Take a look at the echobot example that comes with the source. Definitely check out the Strophe Google group (http://groups.google.com/group/strophe), where you would find Jack Moffitt (creator of Strophe) promptly answers questions himself.

Related

How to integrate AIML chat bot in Web Page

I have a web page where I just play with HTML, CSS and Javascript.
I have decided to create a Chat Bot there.
AIML seems like the way to go, and I already know how to write it.
Question is: After I have my bot.aiml file, what do I do with it?
I assume I need some sort of javascript function to interact with it.
If you only have access to HTML, CSS and JavaScript and not to some server-side technology, then you will need a JavaScript AIML interpreter.
A quick search turns up the following:
AIML Interpreter written in node.js
AIMLInterpreter is a module that allows you to parse AIML files and to find the correct answer to a given message.
aiml-high written in node.js. Built on aimlinterpreter.
aiml-high is a module that allows you to parse AIML files and to find the correct answer to a given message.
Surly2
a half-complete node.js AIML interpreter with a bad attitude.
Surly2 is a remake from the ground up of Surly using Node 5 and using as much asynchronicity as possible.
burly
Burly is a fork of Surly2
I too searched for the same but sadly i was not successful of creating my own bot..instead i found a website which will do exactly the same instead of we reinventing the cycle...
Create your account over here
http://www.pandorabots.com/botmaster/en/new-account
After signing in you have option of uploading your own AIML file and use the deafult AIML files and also Custom HTML and much more....
ChatterBean can help you to interpret the AIML files. From Alicebot.org,
ChatterBean is an AIML interpreter (also known as "Alicebot") written in pure Java.
For integration with Web, host a J2EE application with ChatterBean.
Since you already have understanding of chatbot, you can integrate it to your webpage by using php or j2ee (jsp being the easiest) which would send a request to the bot methods and return response.

Understanding Node.js use cases

Trying to understand using node.js for a web applications.
Are there basically 2 major uses cases, i.e.:
The entire system is written in node, so you have functions for login, logout, password recover, and whatever else the web app does. All of this is written in javascript?
You use node.js only for sending the client updates, to have a real-time effect on the app. But the rest of the application is written in e.g. rails or django
Please tell me if I understand this correctly:
In terms of other technologies used with node.js, you tend to see people using node.js as the backend server, socket.io on the client side to establish a cross-browser long running ajax call library, and then you might use backbone.js for your client mvc pattern.
Is this right?
Basically speaking, it is just a tool to run javascript code server side. What you do with it is up to you. Many are using it as a complementary system since it's relatively new, but it's perfectly possible to run an standalone app with node.js.
It's said to be particularly good at handling concurrent connections, which is why it is often recommended to handle real-time jobs within an app, but there is no "obligation" so to speak to use it for this specific use case, it's just one thing you can do.
As with everything, the best way to understand it is to use it, so don't be afraid to play around with it.
Use case for Node js as we are using in our Application
Skype like voice & video chat on chrome browser using node js

Handle Web Server with multiple clients [duplicate]

I am looking for a simple and reliable Comet javascript library. I want to keep a persistent streaming of data from my server (via PHP script) to the client side. I tried building my own using the iframe technique, but there are lots of issues with safari which I experienced. I am just hoping someone else has created a simple library for it?
There is a jquery comet plugin
Probably the best version though is the Dojo library
I have a quick list of commands I used to get a jetty server with comet up and running here
It's not just the javascript library that you need, but a server-side implementation as well. Depending on your needs, you'll need to pick a proper implementation.
You mentioned PHP, which is typically difficult with long-held requests. Other options include having a separate server for your comet requests, or using a SaaS solution, such as WebSync OnDemand.
Depending on which option you pick for the server, you will have one or more javascript clients available. But you need to determine your server implementation first, then use the appropriate javascript implementation to match.
Have a look at http://www.ape-project.org/ Pretty quick setup process.
have you tried JSON-RPC. Apparently Dojo has good support for it, though I haven't tried it thoroughly
JSON-RPC
Dojo Documentation

Developing JavaScript APIs by using Third-Party Librarys

I currently want to make my project accessible not only via back-end code (C#, Python, PHP, etc.), so I decided to write an easy and simple JS API, every developer can easily integrate within their website / project.
Since the whole thing is a service driven system, most of the stuff runs via RPC encoded as JSON.
My problem is, that if I want to make this API I got the following two options:
Writting raw RPC functions from ground up
Using jQuery as third-party library
The big problem with option number 2, which is by far the best option, is that I have to say "dear developer, you need to use jQuery to access my API", which is striking me, since I do not want to dictate what ppl should or should not use by restricting their opportunities.
Is there a way implementing jQuery's RPC stuff without breaking any other potential JS framework the final developer will use?
if you're worried about the conflict between jquery and other libraries, use jQuery.noConflict() and it solves your problem!
more info at : http://docs.jquery.com/Using_jQuery_with_Other_Libraries

Is CouchDB an example of Server Side Javascript?

I looking at using Javascript server side and took a look at persevere/pintura but for a novice like me, I need more documentation and tutorials and CouchDB seems to have a lot of that but is it used as a server side js tool?
Kind Regards
Yes (seconding what #Pointy said above). The JavaScript in CouchDB does run server-side. :)
Beyond that, though, JavaScript in CouchDB can do far more than just map/reduce queries. It's also used for document validation, update handling (for processing XML POSTed to CouchDB for example), as well as HTML or other markup output from either a single JSON document (using _show) or from the results of a map/reduce query (using _list).
CouchDB does not, however, offer filesystem access or TCP/IP listeners as Node.js does. Right now, the JavaScript is focused on the "shipping and handling" for the database contents (things like validation, formatting, and querying).
If you're interested in looking into options for handling things that CouchDB doesn't do "internally" (image processing, sending e-mails, etc), you might checkout my reply about CouchApp architecture options.
CouchApp's are definitely a viable option for web apps. Coupling those with replication, it's hard to beat.
http://nodejs.org/ is a great example for server-side javascript. If you don't want to write your complete webapp on NodeJS you can trigger it via the node command.
CouchDB is a database with an interresting feature, it allows you to interact via a RestFull api making it ideally suited to access over the web, either in javascript or other client environments. If you are looking for a server-side javascript development environment, try Servoy. It allows full featured server-side application development in javascript including easy database access to all major databases.
Short Answer: Yes.
Longer Answer:
There is a Javascript Engine shipped with CouchDB, which is SpiderMonkey
(the very first engine, open source, written by Brendan Eich, creator of javascript)
CouchDB's View function is JavaScript function running server side that acts as the Map half of a map/reduce operation to construct view.
Then there is client side javascript API, which can be used to communicate with the REST layer to fetch/update documents, which is also where jQuery is used by CouchDB.
More on CouchDB's both server-side & client side javascript capability:
The default engine is capable of doing many features, while package availability is limited compared to Node.js. Kan.so can be considered "NPM for CouchDB, where some packages are server side.
For example, there are frameworks like duality that try to make use of both server side & client side javascript capability to reuse code for rendering with couchDB.
More on the engine:
(The selection of spider Monkey over v8 is because for couchDB's use case the map reduce is not v8 designed for. Also include packaging, multi-threading and also historical reason v8 did not exist that time when spiderMoney is chosen) see [the mailing list] and tweet2
There is even project to port the whole CouchDB to Node.js (i.e. instead of Erlang), Chesterfield
I am glad if someone can add how Erlang talk with the javscript engine.
Thanks for everyone's answer, this is an important thing to make clear for people like me messing up couchDB with some Node.js packages
No, CouchDB is a document-oriented database that can be queried and indexed in a MapReduce fashion using JavaScript. CouchDB also offers incremental replication with bi-directional conflict detection and resolution.
http://couchdb.apache.org/
CommonJS can be used for server side JavaScript, see here: http://www.commonjs.org/
NodeJS is another: http://nodejs.org/

Categories

Resources