CE Messenger [PART TWO]

xero
@xero-28ehVN โ€ข Oct 25, 2024

Continued from:
#-Link-Snipped-#


Hey people, its about time to start making pieces and join them. So we'll start with HOWTOs for making pieces.

For a development environment, first of all we'll need all the components needed for server (Hamatchi optional). Apart from that we'll need the following components :-

1. Java development IDE : Eclipse / Netbeans (I'll be using Eclipse)
2. J2SE 5.0 or above
3. Smack ver 3.1.0 api (link <a href="https://www.igniterealtime.org/downloads/index.jsp#smack" target="_blank" rel="nofollow noopener noreferrer">Ignite Realtime: Downloads</a>)

However before proceeding with above stuff I would like to know how many aren't aware of basic OO concepts, as we'll follow these strictly in our project.

I'm also expecting that atleast developers have their hands on with server, and have tested with Spark client ๐Ÿ˜€

And since Shalini is pretty good at teaching, she can help most of you out !

Shoot questions if any !

Happy Learning

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • ms_cs

    @ms-cs-Ab8svl • Apr 18, 2009

    I am having experience with servers like, J2EE server,tomcat, and netbeans,,so I can use the netbeans..I did not use spark...just here I heard about that...What is use of smack api.? It is a time to start...

  • xero
    xero OP

    @xero-28ehVN • Apr 18, 2009

    um.. well we really won't be needing any server as of now and if you are comfortable with Netbeans as your IDE its fine ๐Ÿ˜€

    Spark is just used to test the openfire server configuration.If you haven't done it i would suggest you try to use it once, as our ce messenger functioning would be on similar lines

    With the help of smack api we would communicate with the openfire server through java code.

    Happy learning

  • ms_cs

    @ms-cs-Ab8svl • Apr 19, 2009

    @xero : Whether in this weekend we going to start ah?

  • xero
    xero OP

    @xero-28ehVN • Apr 24, 2009

    hey, I'm sorry for the late reply, I'm pretty caught up on weekdays so, cannot visit CE on weekdays. Well tomorrow (Saturday) I'll be posting first patch of code for a basic authentication with the server. I'll put it in as simplistic manner as possible and will give a brief explanation on it. After that I want to try and run the code, with results to be posted in this thread !!

    Happy Learning

  • durga ch

    @durga-TpX3gO • Apr 24, 2009

    @XERO

    did anyone say "U ROCK?"

  • xero
    xero OP

    @xero-28ehVN • Apr 25, 2009

    Thanks for the compliments Durga, but we all rock ๐Ÿ˜

    The code for basic authentication and chat functionality for created users in server is as follows..


    // Create a connection to the igniterealtime.org XMPP server.
    XMPPConnection con = new XMPPConnection("serverAddress");
    // Connect to the server
    con.connect();
    // Most servers require you to login before performing other tasks.
    con.login("username", "password");
    // Start a new conversation with John Doe and send him a message.
    Chat chat = con.getChatManager().createChat("username2@localhost", new MessageListener() {

    public void processMessage(Chat chat, Message message) {
    // Print out any messages we get back to standard out.
    System.out.println(
    "Received message: " + message);
    }
    });
    chat.sendMessage(
    "Howdy!");
    // Disconnect from the server
    con.disconnect();



    Now that sure looks pretty easy isn't it ๐Ÿ˜€

    The smack API, as mentioned before provides us with a class called XMPPConnection.
    This object is responsible for establishing a connection between the program and server and authenticate with credentials.
    Then we instantiate a Chat object which handles the chatting process with another user.

    The above code has been extracted from #-Link-Snipped-#

    I really want everyone to try the above code. If not to send a message atleast try creating a single user at server and authenticate it via this code. With this you'll be able to get a whiff of how to start with the code ๐Ÿ˜€

    Now those who really couldn't understand what's happening in the code really need to look forward for java tutoring which Shalini had given.

    Happy Learning

  • ms_cs

    @ms-cs-Ab8svl • Apr 25, 2009

    @Xero:nice start...Shall I know the plan of IM?Then only I can understand what is really happening...

    I have sucessfuly compiled with smack api...How to test it? via a browser using jsp? or through command line? How to test that?

  • xero
    xero OP

    @xero-28ehVN • Apr 25, 2009

    Well to start with, we'll first need people to have a good hands on with smack API. So for that we'll play with the API for 2-3 weeks going through assignments like authentication, creating users, chatting etc..

    As per for testing, the above code create two users in server. Log in with one of the users through spark and then use the above program to log in the second user. As an output, you'll the user logged in with spark receive the message "Howdy" ๐Ÿ˜€

    That's the test...

    Similarly you can create a console program which can at least send a spark based user messages. This is a good assignment to start with.

    Happy Learning

  • ms_cs

    @ms-cs-Ab8svl • Apr 25, 2009

    Good Idea...Xero

    While trying to run the program, I got the following

    Exception in thread "main" java.lang.NoClassDefFoundError: s
    Caused by: java.lang.ClassNotFoundException: s
    at java.net.URLClassLoader$1.run(URLClassLoader.java:221)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:209)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:324)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:269)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:337)

  • ms_cs

    @ms-cs-Ab8svl • Apr 25, 2009

    How to run the program ? Is it similar to run the ordinary java programs?

  • xero
    xero OP

    @xero-28ehVN • Apr 25, 2009

    This is just and ordinary java program. Put the whole code in main method, and run it. The issue you reported is related to classpath .

    If you are using Netbeans/Eclipse i don't think you'll face this issue. Also make sure before running the program that the openfire server is up and running properly.

    If you continue to seek the problem, try google ๐Ÿ˜€

  • ms_cs

    @ms-cs-Ab8svl • Apr 26, 2009

    package ceim;

    import org.jivesoftware.smack.*;
    import org.jivesoftware.smack.packet.*;
    import org.jivesoftware.smackx.*;
    import java.util.*;
    import java.io.*;

    public class offreader {
    private static List<String> nodes;
    public static void main(String[] args) throws Exception {
    XMPPConnection con = new XMPPConnection("localhost");
    con.connect();
    con.login("u1", "u1");
    OfflineMessageManager off=new OfflineMessageManager(con);
    off.getMessages(nodes);
    System.out.println(nodes.get(0));
    con.disconnect();
    }
    }

    This program is to display offline messages.
    I have created two users u1,u2; And using spark logged using u1 account.
    And Through u1 I add u2 to my contacts in spark and sent messages to u2[which is offline message]. I run the above program to get those offline messages...It runs ,,,But displays message as null...Why this program fails to display the offline messages?

  • ms_cs

    @ms-cs-Ab8svl • Apr 26, 2009

    xeroThis is just and ordinary java program. Put the whole code in main method, and run it. The issue you reported is related to classpath .

    If you are using Netbeans/Eclipse i don't think you'll face this issue. Also make sure before running the program that the openfire server is up and running properly.

    If you continue to seek the problem, try google ๐Ÿ˜€

    The program you have given now runs correctly...Now only I am using net beans...No need for google now...๐Ÿ˜‰

  • xero
    xero OP

    @xero-28ehVN • Apr 26, 2009

    Wow dude, i appreciate your effort ๐Ÿ˜€
    Seems like are getting a whiff of a stuff already, which's nice ! I'll need to check the latest implementation of offline message manager and will get back to you on the problem you mentioned !

    Happy Learning !

  • ms_cs

    @ms-cs-Ab8svl • Apr 26, 2009

    Thank you xero, Well ,How to have a chat between the two users,

    Can I use ChatManager class,Chat,MessageListener? What are the classes I have to use to chat?

  • xero
    xero OP

    @xero-28ehVN • Apr 27, 2009

    To begin with, you can go through the API Documentation of all the classes which we use in the program. It will help you gather a pristine idea, on how to proceed ๐Ÿ˜€

    And use your own imagination ๐Ÿ˜

    Njoy

  • ms_cs

    @ms-cs-Ab8svl • Apr 27, 2009

    Hmm, After looking the API , I asked this,

    Can I use ChatManager class,Chat,MessageListener? What are the classes I have to use to chat?
  • ms_cs

    @ms-cs-Ab8svl • Apr 27, 2009

    xero// Create a connection to the igniterealtime.org XMPP server.
    XMPPConnection con = new XMPPConnection("serverAddress");
    // Connect to the server
    con.connect();
    // Most servers require you to login before performing other tasks.
    con.login("username1", "password");
    // Start a new conversation with John Doe and send him a message.
    Chat chat = con.getChatManager().createChat("username2@localhost", new MessageListener() {

    public void processMessage(Chat chat, Message message) {
    // Print out any messages we get back to standard out.
    System.out.println(
    "Received message: " + message);
    }
    });
    chat.sendMessage(
    "Howdy!");
    // Disconnect from the server
    con.disconnect();

    Whether here This line, connects username1 to username2"

    Chat chat = con.getChatManager().createChat("username2@localhost", new MessageListener() {......
  • xero
    xero OP

    @xero-28ehVN • Apr 29, 2009

    Hey,
    I'll be out this weekend. So, will try to reply to the thread either on Monday or Tuesday. If i got time, i may come up with snippet which can enable chatting between two users ๐Ÿ˜€

    Happy Learning

  • ms_cs

    @ms-cs-Ab8svl • May 1, 2009

    Chat chat = con.getChatManager().createChat("username2@localho st", new MessageListener() {......

    Whether here This line, connects username1 to username2

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 3, 2009

    @Maro -Where are you ? No posts from your side here ?

    Guys ! Work like a team rather than going alone like a rocket. ๐Ÿ˜€

  • ms_cs

    @ms-cs-Ab8svl • May 4, 2009

    no updates here๐Ÿ˜”

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 4, 2009

    Well, I think me and Maro are lagging far behind you guys ms_cs and xero. I need some time to catch you guys, then only you can get updates from my side.

    Maro, you are also with us right?

    PS: Very lazy in reading these long long threads. ๐Ÿ˜‰

  • ms_cs

    @ms-cs-Ab8svl • May 4, 2009

    I have just tested the program given by xero, and tried one(sending offline messages) but till now not completed that๐Ÿ˜”

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 4, 2009

    [Updates from my side ]

    I am not yet finished with server set up things only and afraid of wasting my one more day again for this. ๐Ÿ˜

  • ms_cs

    @ms-cs-Ab8svl • May 4, 2009

    stop the windows services that give troubles like port conflict...

    If port conflict is a problem this may help you

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 4, 2009

    ms_csstop the windows services that give troubles like port conflict...

    If port conflict is a problem this may help you

    Port conflict was resolved but I don't know why that stupid Apache don't get started at once, it says "Busy" ๐Ÿ˜ก

  • xero
    xero OP

    @xero-28ehVN • May 4, 2009

    Hey Shalini, chill out !!
    Firstly sorry for not replying for a while, i was out on a much needed vacation.

    I guess durga and ms_cs should help out shalini in all possible ways with the setup issues, so that ev'1 is at the same place for pick off.

    And as i had told earlier, we'll spend some time with hands on API before starting with the actual development.

    MaRo seems to be busy these days, however i believe that he won't have any problems in picking this up ๐Ÿ˜€

    N'joy learning !

  • Ashraf HZ

    @Ash • May 4, 2009

    Great to see a lot of activity here. Xero, can you later update the rest of us on the plan once you guys start actual development?

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 5, 2009

    @ms_cs and @durga May I know when can I see you guys online for helping me in setting up environment? I can assure my availability after 10 PM IST. Anyone of you - available at that time?

  • ms_cs

    @ms-cs-Ab8svl • May 5, 2009

    Yes.I will be available after 10IST...I have followed the steps in the document.It works fine now.

    whether these steps worked fine for you?

    Step 1: Unpack the package into a directory of your choice. Please start the
    "setup_xampp.bat" and beginning the installation.

    Step 2: If installation ends successfully, start the Apache 2 with
    "apache_start".bat", MySQL with "mysql_start".bat". Stop the MySQL Server with "mysql_stop.bat". For shutdown the Apache HTTPD, only close the Apache Command (CMD).

    Step 3: Start your browser and type #-Link-Snipped-# or #-Link-Snipped-# in the location bar. You should see our pre-made
    start page with certain examples and test screens.

  • durga ch

    @durga-TpX3gO • May 5, 2009

    Thanks MS๐Ÿ˜€
    @ Shalini. Lady !0 PM IST is 3 am AST! :shock:

  • Ashraf HZ

    @Ash • May 5, 2009

    3am in a weekend should be alright.. *grin*

    Guys, don't forget to compile and organize all the steps (HOWTOs, etc) once your all done with the testing, thanks ๐Ÿ˜€

  • Mayur Pathak

    @mayur-ywQKfu • May 5, 2009

    Can't tell you how happy I am to see the movement on this front. Thank you guys for reviving it. Hope the CE-IM sees the light of the day soon.

    I'm waiting to use it.

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 6, 2009

    xeroTeam List

    • xero (Project Leader)
    • ms_cs
    • shalini_goel14
    • durga

    Can I know the reason why Maro's name is not here ?

    @ms_cs Can you come online at hamachi?

  • Ashraf HZ

    @Ash • May 6, 2009

    shalini_goel14Can I know the reason why Maro's name is not here ?

    @ms_cs Can you come online at hamachi?

    *cough* my bad. I was going through names in this thread ๐Ÿ˜‰

  • xero
    xero OP

    @xero-28ehVN • May 6, 2009

    @Shalini/Ash - I'm removing the team list as of now. We'll discuss the team before the development begins ! Kindly don't discuss the team now, save it for later part ๐Ÿ˜

    @Shalini - How's your environment setup going?

    Happy Learning

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 6, 2009

    xero@Shalini - How's your environment setup going?

    Ya ! Just give me 1 more day. Recent problem I was facing was "Cannot establish connection to the database" while doing database settings as per durga's doc.

    Anyways I am going to do fresh start rather than facing such never ending issues.

  • ms_cs

    @ms-cs-Ab8svl • May 7, 2009

    @Team Members: Thinking that the works going slowly.speedup the works guys

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 7, 2009

    ms_cs@Team Members: Thinking that the works going slowly.speedup the works guys

    Ya ! sure ms_cs,

    *Luckily now apache and mysql is shown as running for me * Touchwood๐Ÿ˜‰

    [โ€‹IMG]

    2 questions:

    1. Above screen means xampp is working as well as installed fine right?
    Then why I am still getting "page load error" on following link : #-Link-Snipped-# or #-Link-Snipped-#

    2. Did you guys mentioned anywhere how to set up database in mysql ? I couldn't find any such information in durga's doc and in all scattred threads of CE-IM ๐Ÿ˜

    [โ€‹IMG]

    Do I need to use above screen to make database, if yes..how? I couldn't see anywhere such options to create database ๐Ÿ˜

    Please answer fast to make work speed up at my end. I want to finish off this thing today only in any case.

  • ms_cs

    @ms-cs-Ab8svl • May 7, 2009

    goto following link

    #-Link-Snipped-#
    and create the database aikon

  • ms_cs

    @ms-cs-Ab8svl • May 7, 2009

    I forget to specify one step, you have to start xampp

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 7, 2009

    ms_csgoto following link

    #-Link-Snipped-#

    I have already tried this link also , a simple #-Link-Snipped-# is not working, forget about phpmyadmin

  • ms_cs

    @ms-cs-Ab8svl • May 7, 2009

    Oh..you can ask CEan durga, to fix this.

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 7, 2009

    ms_csOh..you can ask CEan durga, to fix this.

    Why , what is the thing that durga knows and you don't know? If I will have to ask durga, I will have to spend my 1 more day in this thing only.She is not available now.

    Try ms_cs, if you know and can help me out today only.

  • ms_cs

    @ms-cs-Ab8svl • May 7, 2009

    Sure, But yours post #-Link-Snipped-# indicates that works are going well...SO, I dont understand why it doesnot open the link , #-Link-Snipped-#

    you may try this again,

    1.start xampp again
    2.then go to that link

  • ms_cs

    @ms-cs-Ab8svl • May 7, 2009

    @shalini: everything is fine now?

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 7, 2009

    ms_csSure, But yours post #-Link-Snipped-# indicates that works are going well...SO, I dont understand why it doesnot open the link , #-Link-Snipped-#

    you may try this again,

    1.start xampp again
    2.then go to that link

    Yeah according to that post this time xampp showed no problems to me but I don't know why that link is showing "no page " found error. Anyways leave it ms_cs .

    Thanks !

    PS: The biggest problem-why this project will keep on going sloweeeeeee..ssssst speed is , everyone is not available together at same time.

  • durga ch

    @durga-TpX3gO • May 7, 2009

    @ Shalini,

    I have not documented the DB setup part as I have not done it.
    If I find time this weeke end, I shall do it. I need to first learn it and then do it.

    If you are expecting some one with high expertise , not really. I am learnign and then documenting not that I know stuff and document ๐Ÿ˜€
    @ MS-CS
    Its not team members who need to speed us, its *US*

    @ all.

    Yup, I am in a different time zone.
    May be I can hand over the DB admin part to some on in INDIA and be in more of coordination , than waste time in waiting for others.

  • durga ch

    @durga-TpX3gO • May 7, 2009

    ms_csSure, But yours post #-Link-Snipped-# indicates that works are going well...SO, I dont understand why it doesnot open the link , #-Link-Snipped-#

    you may try this again,

    1.start xampp again
    2.then go to that link

    has OPENFIRE been started?