Strophe MUC example - xmpp

Does anyone have an example code for a join,changenick, ...etc functions calls in Strophe muc extension ?
I tried to do this myself not sure how do i call the extensions functions, and add the plugin to the js, is it adding

You need to include the strophe.muc.js in our html file and after you established a Strophe connection, you can call the muc methods with conn.muc.foobarMethod() where conn is the established Strophe connection and foobarMethod is the method you'd like to call.
Instead of trying to build everything on your own (and from your question I assume that you don't have the relevant know-how), try an already built js xmpp client like Candy which is also built upon Strophe.js.

Candy is a full blown MUC client based on Strophe. The code is excellent and easy to read.
I suggest to download it and study the code:
http://candy-chat.github.com/candy/
Alex

Related

How do I create bot user with webhook on server side in MongooseIM?

This is what I want
A user(bot) that always shows status Online
When a message comes for the user, I will hit a webhook associated with the user
The response from the webhook request will be sent as reply to the sender
This user will be able to intercept any message (let's say for profanity moderation)
This user will be able to send message to anyone (let's say broadcast)
This user will come in every users roster as default(like echo bot of skype)
I can't seem to find any resource on how to achieve this. I've found a way to intercept the incoming packet in openfire but I don't see any easy way to do this with MongooseIM. I haven't started diving deep into the source code yet, still looking for a way to do this without touching the source code and locking myself to a specific version of MongooseIM.
Disclaimer: I'm on the MongooseIM core team.
There are multiple ways this could be achieved. The easiest way to achieve this depends on your familiarity with Erlang, the programming language MongooseIM is written in.
You won't need any Erlang to use the event pusher module with its HTTP backend and the default settings, but you'd need some Erlang to control what messages get forwarded to the HTTP service or to make more complex setups. To send messages back, you'd either need to use the MongooseIM REST API or connect as an ordinary XMPP client to the server using one of the many XMPP libs available out there. This is probably the best approach to achieve your goal.
You can skip using the event pusher and just connect your bot as an XMPP client written in any language whatsoever. The bot might have your business logic within or can forward messages it gets to the HTTP service.
If you're comfortable working in Erlang, then the mechanism to extend the server is called Hooks and handlers and is described in the official MongooseIM documentation. This requires writing code in Erlang and building from source, but does not necessarily require modifying upstream MongooseIM code.
You could use the XMPP component protocol, which allows to extend the functionality of an XMPP server, yet structure it as multiple services. The components may be written in any technology you want and the most popular XMPP libraries should support the component protocol out of the box.
Depending on your choice from the above list and the language and environment you prefer, you might have to pick an XMPP library to use. There are XMPP libs available for iOS (ObjC and Swift), Android (Java and Kotlin), Python, JavaScript, C, and even some emerging ones for Rust, Dart and possibly more.

Smack 4.2 does not include jabber:client in outgoing stanzas

I am using Smack 4.2 to implement a fairly basic XMPP chat client. I am using Prosody XMPP server. Prosody is fairly strict about requiring "xmlns=jabber:client" in all incoming stanzas. Smack 4.2 does not include this attribute in its outgoing stanzas. I have tried extending Bind and Session stanzas, and I can make the connection work that way. But, now I am getting into joining rooms, and I really dont want to modify Smack's MUC code so that it can accept a modified Presence message.
Please help!!
I do not know why Prosody server requires it, there is nothing about it in official XEP-0045 standard https://xmpp.org/extensions/xep-0045.html#enter
Maybe there is a way to disable it at Prosody side somehow
Smack 4.3 does add xmlns to every outgoing IQ: https://github.com/igniterealtime/Smack/blob/master/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java#L518
So that at least solves the xmlns problem.

Using socket.io to Connect with Elixir's Phoenix Sockets

Im trying to connect a Javascript client to a Elixir phoenix socket by using socket.io. Right now what Im doing is this:
var socket = io.connect('ws/ip.adress.of.server/ws');
However Im not getting a connected true socket object:
Can anyone guide me on the correct way to connect to the phoenix socket? Is there any place in my server code where I can look for the URL I need to connect to?
Thanks
socket.io is a dedicated protocol which works on top of websockets or long polling. It leverages similar concepts to those offered by phoenix sockets. But apart from that, those two are two distinct things which are not interoperable. As Justin Wood mentioned, use phoenix.js when you want to use phoenix channels.

File transfer via XMPP (Openfire)

I'm trying to implement file transfer via xmpp, my server is openfire 3.9.3.
I have tried to imitate Sparks' stanzas and I got to a dead end.
please help!
file transfer is already implemented in xmpp servers like openfire.
You need to implement it in client side.
Check strophe js or candy js, there is an API to do this.

Openfire MUC Through HTTP Requests

I've been searching high and low for a plugin that handles MUC administration through HTTP requests for Openfire. I've looked in the plugins and even in the community pages but I've had no luck so far.
Is there a plugin for this? Where can I find it?
If there are none, what are my alternatives aside from creating my own? Kinda like how ejabberd has mod_rest or even ejabberdctl.
If anyone can point me to the right direction, that would be really great!
I ended up creating a service for http requests and linking it to Openfire's MySQL back end. Easier and gives me more control.
Openfire have cache mechanism, Directly operate Mysql table have some issue, User information will delay before openfire cash flush.
I do it by xmpphp, and a new method to add muc room and room member by xmpp protocol, but i need user's password every operation.
If you check again the Plugin site from Openfire you will find out that there is a Plugin for that named "MUC Service". That do exactly what you need.
Here is the documentation: http://www.igniterealtime.org/projects/openfire/plugins/mucservice/readme.html