xmpp learning
download:
Server: Openfire 4.0.2
Client: Spark 2.7.7
Install
Openfire installation:
Follow the prompts to the next step, the server domain name is set to: localhost (ps: if you use gloox, use the machine name directly, because gloox does not recognize ip); the database uses the embedded database or other standard databases.
When using mysql, you need to pay attention to open Openfire with administrator privileges, otherwise the following error will occur:
HTTP ERROR 500
Problem accessing /setup/setup-profile-settings.jsp. Reason:
Server Error
Caused by:
After the installation is complete, log in to the browser: http://127.0.0.1:9090
Spark
Install Spark on two computers, create their own users, add friends to each other, and then you can communicate.
Implement the client yourself
using agsXMPP
It's very easy to use, you can download it directly from the official website. There are detailed examples, but there will be a debug output when the program is running.
在 System.Net.Sockets.SocketException 中第一次偶然出现的“System.dll”类型的异常
tips
The Internet said that it may be a server problem, but I haven't found it for the time being.
use gloox
download gloox
Download address: https://camaya.net/gloox/download/
gloox 0.9.9.12:http://camaya.net/download/gloox-0.9.9.12.tar.bz2
Open gloox.vcxproj directly with vs to run
gloox 1.0.15:http://camaya.net/download/gloox-1.0.15.tar.bz2
There will be problems with opening gloox.vcxproj directly with vs, and the file needs to be modified.
The following provides a gloox that can be run directly in vs2013
svn地址:
gloox-1.0:svn co svn://svn.camaya.net/gloox/branches/1.0
Debug example
- Create a new win32 console empty project, the character set is multibyte
- New filter glox
- Copy the src folder and config.h.win file in gloox to the new project
- Modify the src folder to gloox, and add the files (excluding subdirectories) to the filter gloox
- Load the examples in the examples in the gloox folder for debugging
For example: MyGloox project under MyGloox2015
gloox memory leak
I found that whether I use gloox directly or encapsulate gloox myself, there will be memory leaks. I found several versions and programs written by others, and found that there are memory leaks.
use libstrophe
libstrophe compilation
Download libstrophe-master.zip
Unzip, look at the directories, expat is empty, then download expat, unzip, do not need to compile, put .h and .c under expat\lib.
Then compile expat first, and successfully compile the lib file,
Compile the libstrophe project again, and you will be prompted that there is no parser.c. Looking at the documentation, libstrophe uses expat by default. You can choose libxml2. Enter under src and see that there are parser_libxml2.c and parser_expat.c. Obviously, you can rename parser_expat.c to parser.c. Compiled.
Then compile other example projects, prompting no va_copy. It seems that vc2008 is not compatible with it, but it doesn't matter. Many people must have encountered this problem. Sure enough, just google it, and there is an answer, just #define it.
#ifndef va_copy # ifdef __va_copy # define va_copy(DEST,SRC) __va_copy((DEST),(SRC)) # else # define va_copy(DEST, SRC) memcpy((&DEST), (&SRC), sizeof(va_list)) # endif #endif
or
#ifndef va_copy
#define va_copy(d,s) ((d) = (s))
#endif
- All compiled and passed, test login and message, the api is concise and clear, it is the best xmpp library I have ever seen. Of course, gloox and qxmpp are also very useful, and libjingle is more powerful, and each takes what he needs.
Personally encountered another error:
1>libstrophe.lib(sasl.obj) : error LNK2019: 无法解析的外部符号 _SCRAM_SHA1_ClientSignature,该符号在函数 _sasl_scram_sha1 中被引用
1>libstrophe.lib(sasl.obj) : error LNK2019: 无法解析的外部符号 _SCRAM_SHA1_ClientKey,该符号在函数 _sasl_scram_sha1 中被引用
1>E:\code\C\Local\xmpp\libstrophe-0.8.8\libstrophe-0.8.8\vs2008\Debug\roster example.exe : fatal error LNK1120: 2 个无法解析的外部命令
This problem requires the sasl.c and auth.c files
If that doesn't work please use this:
Can be opened directly with vs2008 and vs2012