XMPP client development (1), xmpp client development
Smack can be used for XMPP client development. After downloading Smack and importing relevant jar files, you can start XMPP client development.
The following code connects the client to the Tigase server and logs on to the server based on the user name and password.
Package Xmpp; import org. jivesoftware. smack. connectionConfiguration; import org. jivesoftware. smack. connectionConfiguration. securityMode; import org. jivesoftware. smack. XMPPConnection; import org. jivesoftware. smack. XMPPException;/*** XMPP Client * @ author HZ * @ since 2014-09-01 * @ version 1.0.0 */public class Client {public static XMPPConnection xmpp_conn; public static ConnectionConfiguration xmpp_conf; // server IP public static String xmpp_ip = new String ("10.3.93.213"); // server name public static String xmpp_host = new String ("tsung213 "); // server port public static int xmpp_port = 5222; // username and password public static String user = new String ("hz_12 "); public static String pass = new String ("123456"); public static void main (String [] args) {conn () ;}// connection server public static void conn () {try {// configure the connection xmpp_conf = new ConnectionConfiguration (xmpp_ip, xmpp_port, xmpp_host); xmpp_conf.setReconnectionAllowed (true); xmpp_conf.setSecurityMode (SecurityMode. disabled); disabled (false); xmpp_conf.setCompressionEnabled (false); // connect and log on to xmpp_conn = new XMPPConnection (xmpp_conf) based on the user name and password; Enabled = true; xmpp_conn.connect (); xmpp_conn.login (user, pass); // obtain the relevant variable String tmp; tmp = xmpp_conn.getConnectionID (); System. out. println ("ConnectionID:" + tmp); tmp = xmpp_conn.getHost (); System. out. println ("Host:" + tmp); tmp = xmpp_conn.getServiceName (); System. out. println ("ServiceName:" + tmp); tmp = xmpp_conn.getUser (); System. out. println ("User:" + tmp);} catch (XMPPException e) {System. out. println ("Error:" + e. toString ());}}}
Running result:
Teaches iphone Development about xmpp protocol for chat clients
It doesn't matter if you reply to yueyueqiu's post platform, because you use http and other protocols for communication, so you only need to communicate according to your own protocol.
XMPP client open-source development with NET should not be developed first
. Net open source is hard to find, good is harder to find, it is also junk to find