Recently in the collation of some of this information, less gossip, let me go straight to the theme:
A. OpenFire configuration installation based on XMPP implementation
1, download the latest OpenFire installation files
Official Download site:
Http://www.igniterealtime.org/downloads/index.jsp#openfire
Download Address:
Exe:
Http://www.igniterealtime.org/downloads/download-landing.jsp?file=openfire/openfire_3_7_1.exe
Zip:
Http://www.igniterealtime.org/downloads/download-landing.jsp?file=openfire/openfire_3_7_1.zip in here OpenFire is the server, Below also has a spark, this is a XMPP protocol communication chats the CS The IM software, it may through the openfire chat conversation.
2, Download complete, if you download the EXE file, the implementation of your installation files, to install. Here I am a zip file. After decompression, copy the OpenFire directory to the C:\Program files\ directory, and be sure to be under the C:\Program files\ directory, so that OpenFire is installed.
3, below we start OpenFire server, and configure it. In the C:\Program Files\openfire\bin directory, there is a openfire.exe file for a light bulb, double-click Execute, and you can see it after startup.
4, click the Launch Admin button to enter the Http://127.0.0.1:9090/setup/index.jsp page, configure the OpenFire server
5, choose the language of Chinese Simplified
Click Continue to enter
6, configure the server domain name
If you are a local visitor, then you can not modify or use the localhost, 127.0.0.1 way
If you are using extranet or LAN access, your address is configured as an extranet or LAN address
7. Select Database
Choose OpenFire, of course you can also choose your database type. such as Oracle, SQL Server, MySQL and so on. If OpenFire does not have a connection driver with JDBC, you need to add a JDBC driver that connects to the database, and the driver is placed in the C:\Program Files\openfire\lib directory
If you are using your own database, you need to do a simple configuration
Jdbc:mysql://[host-name]:3306/[database-name]?rewritebatchedstatements=true
Switch to your own IP and database
Database should be built first.
8, select the feature configuration, the default can be
9, admin mail, you can skip this step
10. Installation Complete
Go to the Administrator console page
11, enter the http://127.0.0.1:9090/login.jsp page, input admin, password Admin login entry
12. After entering, you can see
The server name is the JWChat connection address, you can use Spark, JWChat link this address for IM communication chat ...
At this point, the installation and configuration of the OpenFire has been completed. The next article begins to complete the installation and configuration of JWChat.
Second, the implementation of the Android client
Look at the structure of the project first, and then start parsing the code individually:
The main code is attached, the last is the download address
@Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);
Setcontentview (r.layout.formclient);
Get intent Username This.puserid = getintent (). Getstringextra ("USERID");
ListView ListView = (ListView) Findviewbyid (R.id.formclient_listview);
Listview.settranscriptmode (Listview.transcript_mode_always_scroll);
This.adapter = new Myadapter (this);
Listview.setadapter (adapter);
Get text Information This.msgtext = (edittext) Findviewbyid (R.id.formclient_text);
THIS.PB = (ProgressBar) Findviewbyid (R.ID.FORMCLIENT_PB);
Message listener Chatmanager cm = Xmpptool.getconnection (). Getchatmanager ();
Send a message to the WATER-PC server water (get own server, and Buddy)//final Chat newchat = Cm.createchat (this.puserid+ "@water-pc", null);
Final Chat newchat = Cm.createchat ("lee@water-pc", null);
Final Chat newchat1 = Cm.createchat ("chai@water-pc", null);
Final Chat newchat2 = Cm.createchat ("huang@water-pc", null); Cm.addchatlistener (New Chatmanagerlistener () {@OvErride public void chatcreated (Chat Chat, Boolean able) {Chat.addmessagelistener (new MessageListener () { @Override public void ProcessMessage (Chat chat2, message message) {LOG.V ("--tags--", "--tags-form--" +mess
Age.getfrom ());
LOG.V ("--tags--", "--tags-message--" +message.getbody ()); Receive messages from WATER-PC server water (get your own server, and Buddy) if (Message.getfrom (). Contains (puserid+ "@water-pc")) {//Get users, messages
, time, in string[] args = new string[] {Puserid, message.getbody (), Timerender.getdate (), ' in '};
Take out in handler to display messages Android.os.Message msg = Handler.obtainmessage ();
Msg.what = 1;
Msg.obj = args;
Msg.sendtotarget ();
else {//message.getfrom (). Cantatins (Get the users, groups, admin messages on the list);
Get user, message, time, in string[] args = new string[] {message.getfrom (), Message.getbody (), Timerender.getdate (), ' in '}; Take out in handler to display messages Android.os.Message msg = Handler. Obtainmessage ();
Msg.what = 1;
Msg.obj = args;
Msg.sendtotarget ();
}
}
});
}
});
Attachment Button Btattach = (button) Findviewbyid (R.id.formclient_btattach); Btattach.setonclicklistener (New Onclicklistener () {@Override public void OnClick (View arg0) {Intent Intent
= new Intent (formclient.this, Formfiles.class);
Startactivityforresult (Intent, 2);
}
});
Send Message Button btsend = (button) Findviewbyid (r.id.formclient_btsend); Btsend.setonclicklistener (New Onclicklistener () {@Override public void OnClick (View v) {//Get text String
msg = Msgtext.gettext (). toString ();
if (msg.length () > 0) {//Send message Listmsg.add (new msg (Puserid, MSG, timerender.getdate (), "out"));
Refresh Adapter adapter.notifydatasetchanged ();
try {//Send message to Xiaowang newchat.sendmessage (msg);
Newchat1.sendmessage (msg);
Newchat2.sendmessage (msg); catch (XmppexCeption e) {e.printstacktrace ();
} else {Toast.maketext (formclient.this, "Please enter information", Toast.length_short). Show ();
//Empty text Msgtext.settext ("");
}
});
Accept file Filetransfermanager Filetransfermanager = new Filetransfermanager (Xmpptool.getconnection ());
Filetransfermanager.addfiletransferlistener (New Recfiletransferlistener ()); @Override protected void Onactivityresult (int requestcode, int resultcode, Intent data) {Super.onactivityresult (
Requestcode, ResultCode, data); Send attachment if (requestcode==2 && resultcode==2 && data!=null) {String filepath = Data.getstringextra ("
FilePath ");
if (filepath.length () > 0) {sendFile (filepath); }
}
}
Finally, you can not forget the project code, the address is:
http://download.csdn.net/detail/sky_monkey/5820879