|
Don’t DELAY! Don't procrastinate. Come on in and see what we've got on create a blog for you today! Your success is directly related to the quality of your research. And, let me tell you the blog research here is excellent.
Develop your own MSN java client.
Now, use msnmlib 1.2(the website is in Korean), you can write programs as client to MSN servers. You can write msn robots or your own MSN Messenger use Java.
Here I have a very short tutorial on how to use msnmlib 1.2, and my Java development IDE is Eclipse 3.0
Prepare:If you had already downloaded msnmlib 1.2 package from the offical project website, then unzip it to any folder on your HDD.Here I use d:java_devcommon ,you will get a jar file: msnm.jar.Otherwise, you have to download the latest version of msnmlib from the offical web site or the project page on sourceforge
First step, open your Eclipse IDE and use New Project wizard to create a new java project in your default workspace(ofcoz, you can use another workspace), and name your project(here I use jRCS,which means java Realtime Customer Servcie System)
Second, In Eclipse, Select menu Window--> Prefence, expand the Java node in the left treeview, and then expand Build path node in Java node, and then select node User Libraries. We will add a new user library refer to the path where you place your msnmlib jar file. Click new... to add a new user library MSN_LIB and click Add Jars... to make the user library variable refer to msnmlib jar file:d:java_devcommonmsnm.jar
Now, edit properties of project jRCS by select the context menu of jRCS node in the Project Explorer. Here we will edit the Java Build Path and add a new library for this project. Of coz, we will add the pre-defined User Library MSN_LIB here.
Ok, finally, we have our development environment set up. It's time for coding!
Coding Step 1: Create your own MsnAdapter class for an adapter that can listen to the events fired by MSN Messenger. You should make you adapter class extend from the parent class rath.msnm.event.MsnAdapter. the MsnAdapter class has more the 10 methods for event listening. but you have not to implement all the methods, and by user Eclipse New Class Wizard, it is not a hard job to implement a lot of methods. For short and easy, We only implement method MsnAdapter.instantMessageReceived(SwitchboardSession ss, MsnFriend friend, MimeMessage mime). Method instantMessageReceived is invoked by the MsnMessenger instance every time when you receive a new message (MimeMessage) from MsnFriend. Here is my code to reply to the friend "How are you doing":
public class MSNAdapter extends MsnAdapter { MSNMessenger msn;
public MSNAdapter(MSNMessenger msn) { this.msn = msn; }
public void instantMessageReceived(SwitchboardSession ss, MsnFriend friend, MimeMessage mime) { System.out.println(friend.getFriendlyName() +" send me some msg:"+mime.getMessage()); try { // create a new message MimeMessage mm = new MimeMessage();
// remember to append the
trail to // your message mm.setMessage("How are you doing?
"); // set the message kind to MESSAGE -_-!!! // you have to do this. mm.setKind(mm.KIND_MESSAGE); if (robot.msn.sendMessage(mm,ss)) { // message sent successfully System.out.println("send msg ok!"); }else{ // failed System.out.println("send msg faild!"); } }catch(Exception e){ e.printStackTrace(); } } }
Coding Step 2: Write a public class with the static main method as your own msn client.
public class Client {
public static void main(String[] args) { Email = "your@hotmail.com"; Password = "you_msn_account_password"; // create a new MSNMessenger instance msn msn = new MSNMessenger(Email,Password); // set the initial status to online. msn.setInitialStatus(UserStatus.ONLINE); // register your pre-created adapter to msn msn.addMsnListener(new MSNAdapter(msn)); // login into the msn network msn.login(); System.out.println("Waiting for the response...."); } }
Coding Step 3: Debug or run your application.In the context menu of project jRCS, select Run --> Java Application, Eclipse will compile the code and run the application in the Console. If you have your msn account set properly, and you have another msn account that add this msn account as contact, you will see this msn account log in, and then you can send some message to this contact as you wish, how ever the Contact will only and always answer you "How are you doing?".*_^
About the Author Ivan Shi, Web Server System Developer living and working in Shanghai,China He has a Blog "Technically Blog Ivan"(http://www.ivanshi.com/), blogging his life,feel,mind and technology. He is doing a lot to make his speaking and writing English much more better!
I hope it saves you some time, too. If you have more questions, try taking a look at our additional create a blog articles. They can be a great help too.
Add a Comment
|
|
Recommended Blog Products
Warning: unlink(/home/vpsites/domains/veroblog.com/public_html/about_blog/create_a_blog_18940.cb.php) [function.unlink]: Permission denied in /home/vpsites/domains/veroblog.com/public_html/CB.php on line 48
Warning: fopen(/home/vpsites/domains/veroblog.com/public_html/about_blog/create_a_blog_18940.cb.php) [function.fopen]: failed to open stream: Permission denied in /home/vpsites/domains/veroblog.com/public_html/CB.php on line 74
Warning: fwrite(): supplied argument is not a valid stream resource in /home/vpsites/domains/veroblog.com/public_html/CB.php on line 75
Warning: fclose(): supplied argument is not a valid stream resource in /home/vpsites/domains/veroblog.com/public_html/CB.php on line 76
|
|
Other Blog Articles
Snob-Bloggers: You Just Might Be A Snob If You Publish A Blog
You Might Be A Snob-Blogger If
According to Jupiter Research, about 2 percent of the online community has created a blog. That works out to millions and millions of blogs, and in turn, millions
Benefits to RSS
<br />RSS streamlines communication between publishers and readers. Since RSS has had a popularity surge, webmasters have been experimenting and using RSS feeds to deliver content in new and innovative
Mainstream media has become a single-minded authority on how we should perceive life. Theirs is a negative perspective. Could there be a new way of hearing the stories we feel are relevant in our lives?
If youre anything like me you are really getting tired of the mainstream medias one-voice-to-many analysis of life on Earth. First of all, its just too negative! I read a survey recently
What's in a (TLD) name?
They're pushing for a top level domain (TLD) exclusively for porn sites. Im quoting from <a href="http://www.babnet.net/en_detail.asp?id=1224" target="_blank">this
To Blog or Not to Blog: Are Blogs Becoming More Popular than Forums, Newsletters and E-zines?
<br />Blogging is hot, and seems to be becoming hotter each month. Although blogging originally was dismissed, by many successful publishers and other online "gurus", the truth is that
|
|
Recent Blog News
Blog backlash over NUJ Israel boycott - Journalism.co.uk
Blog backlash over NUJ Israel boycott Journalism.co.uk, UK - 7 hours ago Writing at the union's official centenary blog, established at WordPress.com with a remit to cover the meeting, Olivia Lang said: "There is no need for such ...
China blocks video-sharing, blog sites - About - News & Issues
China blocks video-sharing, blog sites About - News & Issues, NY - 8 hours ago Reporters Without Borders reports that China has blocked the French sites Dailymotion (video-sharing) and Canalblog (a blog tool), adding that French sites ...
Diplomat's blog leads to new online rules (UPI)
The British government is eyeing new regulations regarding officials' Internet use after one of its diplomats detailed his time in Bangkok on an online blog. In the wake of last week's scandal involving British embassy official Ian Proud's decision to
|
|