CE Messenger [PART TWO]

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 Ignite Realtime: Downloads)

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

  • ms_cs
    ms_cs
    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
    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
    @xero : Whether in this weekend we going to start ah?
  • xero
    xero
    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 ch
    @XERO

    did anyone say "U ROCK?"
  • xero
    xero
    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
    @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
    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
    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
    How to run the program ? Is it similar to run the ordinary java programs?
  • xero
    xero
    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
    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 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
    xero
    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 πŸ˜€
    The program you have given now runs correctly...Now only I am using net beans...No need for google now...πŸ˜‰
  • xero
    xero
    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
    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
    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
    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
    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
    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
    Chat chat = con.getChatManager().createChat("username2@localho st", new MessageListener() {......
    Whether here This line, connects username1 to username2
  • shalini_goel14
    shalini_goel14
    @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
    no updates hereπŸ˜”
  • shalini_goel14
    shalini_goel14
    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
    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
    [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
    stop the windows services that give troubles like port conflict...

    If port conflict is a problem this may help you
  • shalini_goel14
    shalini_goel14
    ms_cs
    stop 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
    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
    Ashraf HZ
    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
    @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
    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 ch
    Thanks MSπŸ˜€
    @ Shalini. Lady !0 PM IST is 3 am AST! :shock:
  • Ashraf HZ
    Ashraf HZ
    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 Pathak
    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
    xero
    Team 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
    Ashraf HZ
    shalini_goel14
    Can 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
    @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
    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
    @Team Members: Thinking that the works going slowly.speedup the works guys
  • shalini_goel14
    shalini_goel14
    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
    goto following link

    #-Link-Snipped-#
    and create the database aikon
  • ms_cs
    ms_cs
    I forget to specify one step, you have to start xampp
  • shalini_goel14
    shalini_goel14
    ms_cs
    goto 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
    Oh..you can ask CEan durga, to fix this.
  • shalini_goel14
    shalini_goel14
    ms_cs
    Oh..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
    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
    @shalini: everything is fine now?
  • shalini_goel14
    shalini_goel14
    ms_cs
    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
    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 ch
    @ 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 ch
    ms_cs
    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
    has OPENFIRE been started?
  • ms_cs
    ms_cs
    durga
    has OPENFIRE been started?
    to perform database settings it is not needed, I think
  • shalini_goel14
    shalini_goel14
    durga
    has OPENFIRE been started?
    Yes ! it was also already started.
  • xero
    xero
    Hey team, i'm really happy to see the progress on Shalini's environment and i'm really grateful to ms_cs and durga for helping her. However there's one thing which is bugging me, and its the doc.

    Thanks to Durga's efforts the first version of doc came alive and it was helpful for all of us, however I don't want to limit the document as "Durga's doc" any more. I want every member of team who has done the environment setup to update the document and add FAQs which could help the future team members.

    For example the DB setup is not mentioned in the document, its NOT responsibility of durga to do it. Everyone is equally responsible for its absence.
    Ms_cs if you are done with the database setup kindly update the document with its steps.

    I'm yet to setup dev environment and will update the document. I've been holding it up due to some operating system issues. However i'll be regular with the code updates.

    PS: kindly call the doc as CE:IM doc πŸ˜€ (I hope Durga won't mind for this !)

    Happy Learning !!
  • ms_cs
    ms_cs
    Thanks xero,

    and sure I will soon update the document too.ie.,CE:IM doc πŸ˜€
  • durga ch
    durga ch
    xero
    PS: kindly call the doc as CE:IM doc πŸ˜€ (I hope Durga won't mind for this !)

    Happy Learning !!
    Thats very much OK with me XERo πŸ˜€ Evry thing needs to be put in the document. irrespective of who does it πŸ˜€
  • shalini_goel14
    shalini_goel14
    I would still really appreciate if any of you can answer my long time back asked question that why I am getting "Page not found" error page on entering #-Link-Snipped-# in browser though my xampp is installed succesfully as well as showing Apache and Mysql "running" in control panel.

    Any ideas or reasons anyone awared of?

    Thanks !
  • durga ch
    durga ch
    Hi Shalini,

    I tried accesing #-Link-Snipped-# on my computer and its OK

    [​IMG]
    [​IMG]

    Is it possible for you to provide apache logs?

    location:
    on XAMPP control panel click on EXPLORE in the right hand side

    then navigate xampp>apache>logs

    may be I can help you out if I can see what's in logs

    By the way the XAMPP control panel what you have posted, shows that APAche is busy.. I doubt if that is the issue.

    MS :you are correct, I could access localhost without openfire. Thanks for that πŸ˜€
  • shalini_goel14
    shalini_goel14
    @Durga Thanks but files in log folder were simply showing blank.πŸ˜€ so no idea one can get from it.

    Anyways I have figured out problem and luckily all server setup as well as database set up is done successfully at my end. 😁

    I have prepared a much better doc and have mentioned problems clearly step wise one by one an individual can face at different stages of environment setting.If anyone need that(especially Maro), that will do all your work max to max in 1 hour only 😁

    @xero Now my next question is I have just created a dummy "aikon" database but what all tables we are supposed to create in it ? Oh yes , testing through Spark client is still pending for me, I guess for it my username need to be added in database. Can you put some more light on Database related things like what all tables are there(if have any) and privileges and accesses and etc..?

    Get set ready for development part soon Please.....

    Thanks to all for bearing my problems. ! πŸ˜€
  • xero
    xero
    Congratulations shalini on setting up the servers πŸ˜€

    Now if you have provided the correct database parameters while configuring the openfire server, the aikon database would have been used by openfire all by itself for the schema creation. As of now we may not need to manually override the existing schema. As per for priviledges we really don't need to think it of it during the development phase, however we'll take it on during later stages.
  • shalini_goel14
    shalini_goel14
    OK then kindly let me know my next step to do as soon as possible

    Oh yes for testing with Spark client, what username and password I am suppose to use. Please tell.

    Thanks !
  • xero
    xero
    start the openfire administration web console. Search for the users link. From there you can create users.

    From the spark client use those credentials along with the server ip address, which would be localhost and start using it πŸ˜€
  • shalini_goel14
    shalini_goel14
    Hey I created two users and now I logged in Spark as one user and try to start a chat with another offline member but that message is not getting immediately updated in chat window on pressing enter but if I open from Actions->Start a Chat, it shows that message which I tried to send by pressing enter. Is this way it should perform in actual or am I doing something wrong? Please answer.

    Thanks !
  • xero
    xero
    Um... well i really don't remember the exact details, but I think its better if we can test it over a hamachi vpn. Does that sound feasible to you sometime tomorrow morning ?

    I'll use your hamachi server to run my spark client and then we can test the messaging thing πŸ˜€

    Waiting for your reply !
  • shalini_goel14
    shalini_goel14
    xero
    Um... well i really don't remember the exact details, but I think its better if we can test it over a hamachi vpn. Does that sound feasible to you sometime tomorrow morning ?

    I'll use your hamachi server to run my spark client and then we can test the messaging thing πŸ˜€

    Waiting for your reply !
    Tomorrow morning not sure, I have few commitments. Is it ok with you now?
  • ms_cs
    ms_cs
    xero
    Um... well i really don't remember the exact details, but I think its better if we can test it over a hamachi vpn. Does that sound feasible to you sometime tomorrow morning ?

    I'll use your hamachi server to run my spark client and then we can test the messaging thing πŸ˜€

    Waiting for your reply !
    How to do that?
  • xero
    xero
    Shalini i'm really sorry i couldn't reply yesterday. Actually I'm really NOT at the best of my health. So kindly consider a few delays in my response.

    Anyway I'm free today as of now, so if possible can we check you environment today?
  • ms_cs
    ms_cs
    @Team: A general suggestion, It will be better if we discuss the things through thread.
  • xero
    xero
    ms don't mind it but i feel threads take things slowly, well if we just test it in quickly we can put the inferences in the thread !
    That would be quicker and smarter, because its really difficult to sort out all problems with just threads !!
  • shalini_goel14
    shalini_goel14
    @ms_cs and xero

    Better if we all involved in CE-IM can set a daily meeting time that would be convenient for each of us and guarantee availability of all of us at same time.

    My proposed timings:
    Weekdays + Weekends Around 10 PM IST
    Weekends In afternoon around 2PM IST

    I can try to change my timings according to you guys.

    I think this would be better for each of us in devoting time here from our busy scheduled life to finish off this CE-IM as soon as possible πŸ˜€
  • ms_cs
    ms_cs
    The convenient time for me is,
    Weekdays + Weekends Around 10 PM IST
  • shalini_goel14
    shalini_goel14
    @ms_cs Cool timings. If you find your rest of team fellows BUSY, don't waste time (if you have any). Go through with Smack API and Openfire things. This information could be of help to your rest of team as well as you also. πŸ˜€
  • ms_cs
    ms_cs
    OkπŸ˜€.Check out my previous posts in this thread. My question on that is still unanswered. Then how can I proceed further.
  • durga ch
    durga ch
    guys,

    can it be made a little earlier?
    Its really not possible for me to be available at 3 am here πŸ˜€
    just think , will you be awake at 3 am to do a meeting? no right??

    do consider my time zone as well. i run 4 hours ahead of you guys,,
  • xero
    xero
    It would be difficult for me to attend discussions at nights. So i'm proposing a small protocol for meetings and let me know if its fine by you all..


    Whole team must try to meet once a week especially on either of weekends in a way that timing is convenient for all e.g
    we can meet at Saturday sometime in the morning like 11 am to 1pm(considering the convenience at timezones of all team members).

    The purpose of the meeting will be as follows
    --the status of last weeks work and next weeks work plan.
    --technical issues facing if any. The technical issues will be taken up only during the initial meets as we all are new with this. However as we proceed it would be preferable if we take it via threads just to avoid lengthy meetings.

    Now meetings should have agendas, so the agenda will be put up on the day before the meeting. And i want everyone to come up with it. Now obviously we won't be able to take it all but will try to keep everyone's interest with it πŸ˜€. So try to make sure that agenda goes in everyone's interest

    In case somebody will not attend the meeting kindly intimate the other team members.

    I would prefer skype meets, instead of IMs, if that's not a problem.

    After the meeting the minutes of the meeting will be posted in the thread.

    Kindly let me know if i'm missing anything.

    Happy learning
  • ms_cs
    ms_cs
    I have no issues with this, and ready to work on this weekend timings
  • xero
    xero
    In addition to what i just posted, it would be really nice if all team members can interact one 2 one with each other as per their convenience. It would really help in knowing each other and will help to work as a team !!

    In the mean time I also want all developers to start studying about the object oriented principles and their applications. It would benefit us in a great deal with the project.

    Happy Learning !
  • ms_cs
    ms_cs
    I agree. In any team,members interaction is important. But, I could not see it in you. Hope to see it in feature.
  • shalini_goel14
    shalini_goel14
    @xero So that means this CE-IM is going to get completed in years rather than in months. Now wait for one more week(Today is Sunday) to just get start with actual work. Whole week no activity on this project. OK no problem. * Sighs * 😐 I don't think so that spending just 1 hour a day could be a problem to anyone. Anyways I will just follow you guys.

    Tell me my work, I am still not able to follow the useful posts of this CE-IM thread.πŸ˜• What xero and ms_cs have done till now? I really have no ideas. I am just after at server settings stage. Next what I am supposed to do? ?

    @ms_cs If you know, you can also answer my questions ok.
  • ms_cs
    ms_cs
    @Shalini:read the previous posts, posted by xero in this thread, which is a small program to login.
    I have tried to display the offline messages in console for a particular user after the login.It runs But it is not worked. Have a look at my previous posts and if possible correct my program.
  • shalini_goel14
    shalini_goel14
    ms_cs
    It runs But it is not worked.
    I have tried that but before knowing more from my side can you clear me the things "It runs but not working" ? How come it is running but not working?
  • ms_cs
    ms_cs
    With out exceptions it runs. but it not displays the offline messages
  • ms_cs
    ms_cs
    Did you try my program? Whether it works for you?
  • shalini_goel14
    shalini_goel14
    ms_cs
    With out exceptions it runs. but it not displays the offline messages
    Same at my end, you tried using ChatManager right?
  • ms_cs
    ms_cs
    and I sent messages through spark to the user who is in offline.
  • ms_cs
    ms_cs
    shalini_goel14
    Same at my end, you tried using ChatManager right?
    yep...πŸ˜” What is the mistake in that program?
  • shalini_goel14
    shalini_goel14
    ms_cs
    yep...πŸ˜” What is the mistake in that program?
    A time back only I tried that only, give me some time I will let you know. Problem till now I noticed is it is not able to even login when I use con.login(). If it works I guess it will show messages.
  • ms_cs
    ms_cs
    No...It login correctly. I have checked it in openfire.
  • shalini_goel14
    shalini_goel14
    ms_cs
    No...It login correctly. I have checked it in openfire.
    How did you checked that in openfire ?
  • ms_cs
    ms_cs
    Go to users tab, if the user is login means , the icon near to that particular username will be highlighted
  • shalini_goel14
    shalini_goel14
    ms_cs
    Go to users tab, if the user is login means , the icon near to that particular username will be highlighted
    Ok ! I will check it tonight. But then why that logged in user is not shown as online when the second user logs in through Spark?
  • ms_cs
    ms_cs
    I have checked by creating the infinte loop after the con.login, so that it will be displayed as online user
  • shalini_goel14
    shalini_goel14
    ms_cs
    I have checked by creating the infinte loop after the con.login, so that it will be displayed as online user
    If it is working by putting infinite loop that means problem is there only. It should get login by using only con.login() once.

    I will look into it today and will surely get back to you tonight. OK , by that time you also keep on trying and update this thread if solved. πŸ˜€

    One more thing, it worked for you by using Offline Manager? I will check your program also tonight.
  • xero
    xero
    Hey all,
    Following is a very small program, which can enable two users to chat with each other, without SPARK as long as you want πŸ˜€


    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;

    import org.jivesoftware.smack.Chat;
    import org.jivesoftware.smack.MessageListener;
    import org.jivesoftware.smack.XMPPConnection;
    import org.jivesoftware.smack.XMPPException;
    import org.jivesoftware.smack.packet.Message;

    public class BasicSmackClient {
    public static void main(String[] args) {
    XMPPConnection connection = null;
    try {
    boolean closeChat = false;
    String username=null, password=null, recipient=null;
    connection = new XMPPConnection("127.0.0.1");

    connection.connect();
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Enter username : ");
    username = br.readLine();
    System.out.print("Enter password : ");
    password = br.readLine();
    connection.login(username, password);
    System.out.println("Login successful");
    System.out.println("Welcome to smack client\nType 'close' to exit the progam");
    System.out.print("Enter message recipient : ");
    recipient = br.readLine();
    if(recipient.equals("")){
    recipient=username+"@127.0.0.1";
    }else
    recipient+="@127.0.0.1";

    Chat chat = connection.getChatManager().createChat(recipient, new MessageListener() {
    public void processMessage(Chat chat, Message message) {
    System.out.println(message.getFrom()+": " + message.getBody());
    }
    });
    String message;
    while (!closeChat) {
    System.out.print(username +" : ");
    message = br.readLine();
    if(message.equals("close"))
    closeChat = true;
    else
    chat.sendMessage(message);
    }
    System.out.println("Exiting from client. Thanks for using it");

    } catch (XMPPException e) {
    System.out.println("connection error");
    }catch(IOException ioe){
    System.out.println("IO error");
    }finally{
    connection.disconnect();
    }
    }
    }


    All you need to do, is run two instances of about code, login one with user1 and set recipient as user2 and login the second with user2 and use recipient as user1 πŸ˜€

    Try to execute it and let me know the results.

    As per the OfflineMessageManager, it seems like the server will only flush the offline messages if user will intimate the server of its Presence. Well we haven't used any Presence stuff here, so kindly ignore that as of now.

    You can edit the above code as per you requirements.

    Have FUN !!

    Happy learning
  • shalini_goel14
    shalini_goel14
    Hey xero,
    Just now I tried the above program

    I have a user with username: user and I login it through Spark and I have one more user with username: shalinig and I login it through the code. I tried sending a message "hello" from Spark to shalinig
    user: hello
    Folowing is what happened at my side when I tried to run above program.
    Enter username : ​
    shalinig​

    Enter password : ​
    shalinig​

    Login successful
    Welcome to smack client
    Type 'close' to exit the progam
    Enter message recipient : user
    shalinig : ​
    hello​

    shalinig : user@127.0.0.1: null
    ​
    Where could be problem ? Any ideas?
  • xero
    xero
    I'm expecting that you have created two users in the openfire named shalinig and user.

    Now you can continue either way. 2 instances of above code or one instance of above code and another user in spark.

    Steps for the later procedure:

    1. Login spark with user user
    2. start the above program and login as shalinig and message recipient as user

    Try the above steps and let me know.
  • shalini_goel14
    shalini_goel14
    Yes I have created both the users in Openfire first and checked their credentials through Spark also.

    I tried your told second procedure and transferring of messages is not happening. The similar kind of problem I was facing with your earlier piece of code also.
  • shalini_goel14
    shalini_goel14
    Those who are facing problem as mentioned by me in post # 95 in this thread, Please make sure that domain given while setting server in openfire exists. Better give it as localhost. If done wrong, no issues Go to Server settings in Openfire and change xampp.domain entry to 'localhost' there.

    My problem solved.Hope it may solve your problem also. πŸ˜€

    @Maro I am still waiting for your posts in this thread. Be fast and quick πŸ˜€

    Next step: Play with Smack API using latest code shared by xero in this thread and can follow following doc for Smack
    #-Link-Snipped-#
  • MaRo
    MaRo
    Hey CIC,

    long time, I've gone throw the topic quickly, seems great progress coming up πŸ˜‰

    In the meantime I can't help, but in the next few weeks I can have part-time CE-IM work.

    Sorry for being late in reply & less showing in CE, but it's all really out of my control.

    Happy CE-IMing!
  • shalini_goel14
    shalini_goel14
    MaRo
    Hey CIC,

    long time, I've gone throw the topic quickly, seems great progress coming up πŸ˜‰

    In the meantime I can't help, but in the next few weeks I can have part-time CE-IM work.

    Sorry for being late in reply & less showing in CE, but it's all really out of my control.

    Happy CE-IMing!
    Hi Maro,

    CIC -Full form Please ? Maro πŸ˜€
    Its ok if you are busy and everyone here is doing kind of part-to-part time job for CE-IM 😁. We will surely and happily wait for you after few weeks. πŸ˜€
  • MaRo
    MaRo
    Obvious..Ce-Im Crew 😁
  • shalini_goel14
    shalini_goel14
    MaRo
    Obvious..Ce-Im Crew 😁
    Cool man, GM(Genius Maro) 😁
  • shalini_goel14
    shalini_goel14
    Hey CIC,

    Anyone here having enough time and is willing to work on this today ?
  • xero
    xero
    Hey, Shalini, sorry I couldn't get time this weekend. However I can spare an hr on the following weekdays.

    By the way how's the exploration going, could you make out something else out of the current domain ??

    Njoy Learning !
  • shalini_goel14
    shalini_goel14
    Its ok man, I tried soemthing with Roster. I tried to create a Group using that and added a user into desired group from program but need to try more as it shows pending for user for which I added through program but no request message to the other user to whom request is sent. I guess I need to look how to approve user's request through code or πŸ˜•
  • xero
    xero
    Hey, people, sorry for the delay in replying. It seems like under my current work pressure, its getting really difficult to even visit CE and proceeding with the project and it is going to be like that till June. So I won't be available till June. However if i got sometime i'll keep posting code snippets along with brief explanations πŸ˜€
    In the mean time, if interested you can take the following assignments:
    1. Creating a program for chatting with multiple users over the console
    2. Learning about Roster and Presence

    Keep posting the codes in the thread, if possible I can help with the issues.

    Sorry for the inconvenience.

    Happy Learning !
  • shalini_goel14
    shalini_goel14
    So everyone got busy in their work and life but I am still there on the ship. Wow. ! 😁

    No problems xero. Carry on your work. Hope will see you and everyone back in the crew soon. πŸ˜€ and yes I will also post something here.
  • shalini_goel14
    shalini_goel14
    @xero
    Few things I need to know for following:
    " Creating a program for chatting with multiple users over the console "

    You want me to make a single program for allowing multiple users to login-right? Done
    You want me to allow all users to do chat using same console window or want me to make use of Swings in a single program for opening separate window for each login?

    Please make it clear if possible and have time.

    Thanks !
  • Mayur Pathak
    Mayur Pathak
    What next? Has the coding started?
  • shalini_goel14
    shalini_goel14
    mayurpathak
    What next? Has the coding started?
    Well, cannot call it coding exactly but yes work is in progress. Right now R & D for learning usage of Smack API is going on with only 1 member in the crew. You want to make any contributions to this ? πŸ˜‰
  • Mayur Pathak
    Mayur Pathak
    I can, as long as its not about coding
  • shalini_goel14
    shalini_goel14
    mayurpathak
    I can, as long as its not about coding
    Ya sure Sir πŸ˜€, you can even I was also new to all the things going into it. I will tell you your work. Today I will send a doc(detailing each and every step clearly) to you to set up everything in your system. You can help us in making good UI I guess. πŸ˜‰
  • Mayur Pathak
    Mayur Pathak
    Sure go ahead. I'll try my hand on it.
  • manusaluja
    manusaluja
    me too want to join this, what i will have to do for this?
  • shalini_goel14
    shalini_goel14
    @Mayur Sir & mansaluja,

    Very Glad to see helping hands here but I have a question for both of you.I am not sure our Big Boss(xero) here would like you to be with him or not. But most welcome from my side till he says "No" πŸ˜›. A question for both of you . Just answer that before we go further.

    "Suppose you are in very need of money or any other thing you are dying for and someone is ready to give that to you but just asks you to make an Instant Messenger for him/her(Note: your own made), then what would you ?"

    Thanks !
  • manusaluja
    manusaluja
    Hi Shalini.

    what kind of question is that, i mean i didnt got that.
    CE Lab is something where multiple hands will work to make something good and perfect.
    If its something kind of freelancing, I dont mind making it in exchange of money..

    Manu
  • shalini_goel14
    shalini_goel14
    manusaluja
    Hi Shalini.

    what kind of question is that, i mean i didnt got that.
    CE Lab is something where multiple hands will work to make something good and perfect.
    If its something kind of freelancing, I dont mind making it in exchange of money..

    Manu
    Cool man, so Please go through the whole thread and related links in it once, set up everything in your system and let us know. πŸ˜€

    Thanks !
  • manusaluja
    manusaluja
    shalini_goel14
    Cool man, so Please go through the whole thread and related links in it once, set up everything in your system and let us know. πŸ˜€

    Thanks !
    This was the first thread you know I got while googling and that persuaded me to JOIN CE. Its already done on my official system, and will set up also at my home. Do we have some kind of versioning repository for CE where i can keep my code in sync.
  • shalini_goel14
    shalini_goel14
    manusaluja
    This was the first thread you know I got while googling and that persuaded me to JOIN CE. Its already done on my official system, and will set up also at my home. Do we have some kind of versioning repository for CE where i can keep my code in sync.
    Is your code ready? And Please do get in touch with CEan xero.

    Thanks !
  • shalini_goel14
    shalini_goel14
    Hey xero,

    I tried a test Program for use of Roster for knowing the status of all contacts added in one's list(here example of "User" )

    package com.crazyengineers.im.authentication;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.Collection;
    import org.jivesoftware.smack.Roster;
    import org.jivesoftware.smack.RosterEntry;
    import org.jivesoftware.smack.XMPPConnection;
    import org.jivesoftware.smack.XMPPException;
    import org.jivesoftware.smack.packet.Presence;
    /*
     * author shalinig
     */
    public class RosterTest {
      public static void main(String[] args) {
       XMPPConnection connection = null;
       try {
        String username = null, password = null;
        connection = new XMPPConnection("127.0.0.1");
        connection.connect();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter username : ");
        username = br.readLine();
        System.out.print("Enter password : ");
        password = br.readLine();
        connection.login(username, password);
     
        Roster roster=connection.getRoster();
     
        /* Gives the list of contacts added */
        Collection entries=roster.getEntries();
     
        for(RosterEntry entry: entries){
         Presence presence=roster.getPresence(entry.getUser());
         if(presence.getType()==Presence.Type.available){
          System.out.println(entry.getName()+" is online.");
         }
         else{
          System.out.println(entry.getName()+" is offline.");
         }
     
        }
     
       } catch (XMPPException e) {
        System.out.println("connection error");
       } catch (IOException ioe) {
        System.out.println("IO error");
       } finally {
        connection.disconnect();
       }
      }
     }
    
    In above program contacts list for "User" is as follows (as seen from Spark currently )

    [​IMG]

    So above piece of code when made run without Spark would give the output as follows:
    Output:
    Enter username :
    user

    Enter password : ​


    user

    Shalini is online.
    Admin is online.
    User1 is offline.
    User2 is online.​
    It shows all the contacts added in the list of "User" alongwith their Presence status.​

    Please check if I am going on right track. πŸ˜€β€‹

    Thanks !​
  • shalini_goel14
    shalini_goel14
    Final time asking, if anyone is interested in this any more, Kindly let me know as soon as possible otherwise assume "No" from my side here.

    Thanks !
  • xero
    xero
    I looked at the code, and yes, you are on the right path πŸ˜€.

    Now regarding the UI, yes we have to use swing for now. Although I'm dreaming about using AJAX πŸ˜€

    Anyway, as of now we'll stick to swing framework for starters.
  • shalini_goel14
    shalini_goel14
    Thanks !

    For Ajax we need to create js pages , any ideas how to make UIs with that or currently proposed technolgies? Do one has to go for Swings with Ajax?

    PS: If any of you serious about CE-IM , let me know. For next 3 months I am not sure of my commitment for this. I can see it after that only -that also not complete sure.
  • xero
    xero
    I myself don't have knowledge about AJAX, but i have knowledge of Swings. So if its fine we can go ahead with that.
  • shalini_goel14
    shalini_goel14
    xero
    So if its fine we can go ahead with that.
    If I am not wrong, you mean to say "So if its fine you can go ahead with that" where you=Shalini right?

    See,I can find some time from my daily routine for this if and only if you guys take it seriously like me. You people keep on saying -"We are serious" but when the time comes for "We" you make it "You"
  • manusaluja
    manusaluja
    why to go with pure AJAX, when there are good readymade AJAX components available.
    there are some AJAX Frameworks also. Anyways considering ajax means we are going to make web version of this CE-IM, are we also going to make standalone app just like spark???
    would be good if are clear on our strategies, and do have real plans instead of only bieng serious about making it...
  • Ashraf HZ
    Ashraf HZ
    If I'm not mistaken, Xero's aim is to get the team to be familiarized with the development tools. After that, a proper plan with be made πŸ˜€
  • MaRo
    MaRo
    Want to understand something here, CE-IM will be a web application or desktop application?
  • ms_cs
    ms_cs
    @Team: exams will be finished by this weekend. After that, I can work in this. Sorry for the inconvenience.
  • xero
    xero
    woao, lot of queries.. πŸ˜€

    Shalini, please don't consider that I'm pointing a single being for handling a project, If out of last 13 pages of discussion on this thread and just 3/4 snippets of code is making you feel that I'm relying on single person for the whole project then I regret for such an impression.

    Manusaluja, using AJAX was just an idea. I'm familiar with the frameworks but again as you mentioned, currently we are targetting to make something like the spark client πŸ˜€ and kindly don't use words such as strategies and real plans, i really find them overrated 😁

    MaRo, as of now we'll make a desktop application for a start. However we can think on a final concrete interfacing later on. Our primary goal for this thread is however a basic desktop agent with max functionalities covered similar to a spark client.

    ms_cs, glad to see you back.

    Happy Learning !
  • xero
    xero
    Oh ash, sorry to mention your query πŸ˜€

    Yes you are very correct, the primary goal of this thread is for the members to familiarize with the development tools.
  • shalini_goel14
    shalini_goel14
    xero
    Shalini, please don't consider that I'm pointing a single being for handling a project, If out of last 13 pages of discussion on this thread and just 3/4 snippets of code is making you feel that I'm relying on single person for the whole project then I regret for such an impression.
    See Mr xero, I don't know your way of working and interacting with your so called team but I know one thing I don't have enough time to make the things crawling like tortoise. I like going very fast and finish the things as soon as possible. Many things are already lined up for me.

    PS: I am giving up from here. Best of Luck for your learning and trials.

    Thanks !
  • xero
    xero
    Shalini: Its fine and thanks for your support.

    Have a great time !
  • shalini_goel14
    shalini_goel14
    xero
    Shalini: Its fine and thanks for your support.

    Have a great time !
    Welcome 😁
    and yes I will have a great time.
  • xero
    xero
    Ok people now its time almost time to wrap this thread... lets have a gist of progress(even though not much πŸ˜‰ ) happened -

    1. Development environment setup and testing with spark
    2. Introduction to smack api by examples of api usage of chat, Roster and presence.

    Even though our primary aim of this thread was to end up with a stable console based program with basic functionality, the current progress is appreciable πŸ˜€

    The rest of thread will primarily comprise of QnA regarding the things we've done yet. In the mean time i'll start a new thread with their objectives πŸ˜€

    Happy Learning
  • Ashraf HZ
    Ashraf HZ
    Awesome!

    Great work guys πŸ˜€ You guys should try compiling a quick tutorial on how to set up and work with the development tools, so others joining later can quickly keep up.
  • shalini_goel14
    shalini_goel14
    ash
    Awesome!

    Great work guys πŸ˜€ You guys should try compiling a quick tutorial on how to set up and work with the development tools, so others joining later can quickly keep up.
    If anyone need that , can take it from me or Maro also(I gave him also last week)

    @MaRo Hope it was of some use to you? πŸ˜€
  • ms_cs
    ms_cs
    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 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?
  • xero
    xero
    Getting an offline message ain't that easy as it looks. Jabber protocol has mentioned a way on how to get an offline message. Its binded with some subscription of presence of a user.

    If possible try to find an ebook
    Instant Messaging in Java - The Jabber Protocols

    Again, before using the api its better if you can go through the Jabber protocol before through the smack api. It will cover most of the How-To(s).
  • CEMember
    CEMember
    Hello everyone,

    I went through CE-IM Document shared by Shalini as well as snippets of code shared in this thread. Assuming that being a CEan as well as having enough capability I can join and contribute in this project, I have come out with some basic "Login Page" in Java Swings that allow any user to login and check credentials.

    What all steps I followed to start with

    Step 1: Set up the environment as mentioned in CE-IM Doc shared by Shalini.

    Step2: Created two users using OpenFire
    User 1:
    Username : admin
    Password : password

    User2:
    Username : cemember
    Password : cemember
    Step 3: Downloaded Smack Api 3.1.0 from following URL
    Ignite Realtime: Smack API

    Step 4: Download and installed Netbeans IDE in my local.

    Step 5: Created following as the project strcuture

    [​IMG]

    Step 6: Create LoginPage using Java Swings. Following is the program for it. [Note: If anyone else is interested in this, can modify it to make better.]

    package com.crazyengineers.im.authentication;
    import com.crazyengineers.im.webpages.MainWindow;
    import org.jivesoftware.smack.XMPPConnection;
    import org.jivesoftware.smack.XMPPException;
    /**
     *
     * @author  cemember
     */
    public class LoginPage extends javax.swing.JFrame {
        /** Creates new form LoginPage */
        public LoginPage() {
            initComponents();
        }
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        //                           
        private void initComponents() {
            userNameLabel = new javax.swing.JLabel();
            userNameTxtField = new javax.swing.JTextField();
            passwordLabel = new javax.swing.JLabel();
            submitButton = new javax.swing.JButton();
            ImageLogo = new javax.swing.JLabel();
            headerLabel = new javax.swing.JLabel();
            passwordTxtField = new javax.swing.JPasswordField();
            messageDisplayLabel = new java.awt.Label();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            userNameLabel.setText("UserName");
            userNameTxtField.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    userNameTxtFieldActionPerformed(evt);
                }
            });
            passwordLabel.setText("Password");
            submitButton.setText("Sign In");
            submitButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    submitButtonActionPerformed(evt);
                }
            });
            ImageLogo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            ImageLogo.setIcon(new javax.swing.ImageIcon("G:\\PICTURES\\CE\\CELogo.png")); // NOI18N
            headerLabel.setFont(new java.awt.Font("Comic Sans MS", 1, 14));
            headerLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            headerLabel.setText("Instant Messenger");
            passwordTxtField.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    passwordTxtFieldActionPerformed(evt);
                }
            });
            messageDisplayLabel.setForeground(new java.awt.Color(255, 0, 0));
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(messageDisplayLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(userNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(passwordLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(passwordTxtField)
                                .addComponent(userNameTxtField, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGap(84, 84, 84)
                            .addComponent(submitButton))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(ImageLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGap(28, 28, 28)
                            .addComponent(headerLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap())
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(4, 4, 4)
                    .addComponent(ImageLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(headerLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(messageDisplayLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(1, 1, 1)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(userNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(userNameTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(passwordLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(passwordTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(20, 20, 20)
                    .addComponent(submitButton)
                    .addContainerGap(78, Short.MAX_VALUE))
            );
            pack();
        }//                         
        private void userNameTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {                                                 
    }                                                
        [COLOR=Navy]private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             
             XMPPConnection connection = null;
            MainWindow mainWindowFrame = null;
            try {
                String username = null, password = null;
                connection = new XMPPConnection("localhost");
                mainWindowFrame = new MainWindow();
                
                connection.connect();
                username = userNameTxtField.getText();
                System.out.println("Username : " + username);
                password = passwordTxtField.getText();
                System.out.println("Password : " + password);
    
                connection.login(username, password);
    
                mainWindowFrame.setVisible(true);
                this.setVisible(false);
    
            } catch (XMPPException e) {
                messageDisplayLabel.setText("Invalid credentials !!");
            } finally {
                connection.disconnect();
            }
        }[/COLOR]                                            
        private void passwordTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {                                                 
               messageDisplayLabel.setText("");
    }                                                
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new LoginPage().setVisible(true);
                }
            });
        }
        // Variables declaration - do not modify                     
        private javax.swing.JLabel ImageLogo;
        private javax.swing.JLabel headerLabel;
        private java.awt.Label messageDisplayLabel;
        private javax.swing.JLabel passwordLabel;
        private javax.swing.JPasswordField passwordTxtField;
        private javax.swing.JButton submitButton;
        private javax.swing.JLabel userNameLabel;
        private javax.swing.JTextField userNameTxtField;
        // End of variables declaration                   
    }
    
    As the above program is made using NetBeans IDE so lot of code might go over your head as it is auto-generated by IDE and not allowed to edit even.

    Step 7: When the above code is made to run following output comes. [Please don't laugh - it is just a rough and quick made stuff. Also I have never worked on Swings.First time I made program in Swings.:sshhh: Image used is stolen from CEan Kashish's made GFX. 😐] .

    [​IMG]

    Step 8: Enter anything in Username and Password textfields - you will get following screen

    [​IMG]

    As we entered wrong username so it is quite obvious - "Invalid credentials" message will be displayed.

    Step 9: Now I will enter credential of user1 created in Step 2 [username:admin & password: password ]. [ Currently following screen would be shown though ideally it should take the user to other window that will show list of contacts and other many features(need to be developed) required to be a part of any messenger. ]-UPDATED TO - [Following window will appear but it requires complete designing according to the needs.]

    [​IMG]


    So far this is done. Feel free to ask any doubts regarding coding part.Also you all are free to change code to the BEST look and working. πŸ˜€

    @Maro & @xero Sir, Please give your feedbacks - soon I will come up with a "Phase1 flow diagram" showing what all we can do so that if anyone else interested in this project can get an idea of to do things. One request -it would be really appreciating if both of you or senior CEans can show some interest here. * May be we can have atleast this project completed πŸ˜€ *

    If anyone else is interested please try to make a UI page[Right now using Swings] for next window that need to be shown after successful login for user. Logical part to be done, I will look into it by that time. OK?

    Thanks a lot for feedbacks and support ! πŸ˜€

    [
    Update:
    Code is updated to show a new window[Main Window] on successful login of user. Also corresponding pic for it is also changed. Changed and important coding part is showin in blue colour.
    ]
  • Ashraf HZ
    Ashraf HZ
    Great start, CE Member! Keep it up. Please do provide the Phase 1 flow diagram as soon as you can.
  • CEMember
    CEMember
    ash
    Great start, CE Member! Keep it up. Please do provide the Phase 1 flow diagram as soon as you can.
    Thanks Ash Sir, Following is the flow chart I tried to make few things cleared - if anyone interested , Please start work on it. πŸ˜€

    Also, I will keep on updating it based on other's approach of working and next stage steps.

    [​IMG]
    Thanks !
  • ms_cs
    ms_cs
    @CEMember: I am really appreciating your works.

    And that chat window to send messages , I have already done itin my college mini project. So I will post it here,
  • ms_cs
    ms_cs
    shalini_goel14
    Hey xero,

    I tried a test Program for use of Roster for knowing the status of all contacts added in one's list(here example of "User" )

    package com.crazyengineers.im.authentication;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.Collection;
    import org.jivesoftware.smack.Roster;
    import org.jivesoftware.smack.RosterEntry;
    import org.jivesoftware.smack.XMPPConnection;
    import org.jivesoftware.smack.XMPPException;
    import org.jivesoftware.smack.packet.Presence;
    /*
     * author shalinig
     */
    public class RosterTest {
      public static void main(String[] args) {
       XMPPConnection connection = null;
       try {
        String username = null, password = null;
        connection = new XMPPConnection("127.0.0.1");
        connection.connect();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter username : ");
        username = br.readLine();
        System.out.print("Enter password : ");
        password = br.readLine();
        connection.login(username, password);
     
        Roster roster=connection.getRoster();
     
        /* Gives the list of contacts added */
        Collection entries=roster.getEntries();
     
        for(RosterEntry entry: entries){
         Presence presence=roster.getPresence(entry.getUser());
         if(presence.getType()==Presence.Type.available){
          System.out.println(entry.getName()+" is online.");
         }
         else{
          System.out.println(entry.getName()+" is offline.");
         }
     
        }
     
       } catch (XMPPException e) {
        System.out.println("connection error");
       } catch (IOException ioe) {
        System.out.println("IO error");
       } finally {
        connection.disconnect();
       }
      }
     }
    
    In above program contacts list for "User" is as follows (as seen from Spark currently )

    [​IMG]

    So above piece of code when made run without Spark would give the output as follows:
    Output:


    It shows all the contacts added in the list of "User" alongwith their Presence status.​

    Please check if I am going on right track. πŸ˜€β€‹

    Thanks !​
    @CEMember: this code can be used to check the presence of users.
  • CEMember
    CEMember
    ms_cs
    @CEMember: I am really appreciating your works.

    And that chat window to send messages , I have already done itin my college mini project. So I will post it here,
    Thanks ! I am waiting for your post then.

    ms_cs
    @CEMember: this code can be used to check the presence of users.
    Yes I know, I have gone through the whole thread. It was done by Shalini.

    If possible man, Do post the code for opening new window on successful "Sign In" . Also you can check my previous snippets of code done here πŸ˜”
  • ms_cs
    ms_cs
    Better thing is developing command line programs first, then GUI
  • CEMember
    CEMember
    ms_cs
    Better thing is developing command line programs first, then GUI
    okies then you go the way you want to go and let me go with my way of working. πŸ˜€ Any doubts , do ask. Keep on posting your command line programs here also.
  • CEMember
    CEMember
    Ok guys, FTI [For Those Interested ] - my previous first step code is changed so that a new window[Main Window] is opened now on successful login of user.

    Now those who have good hands on Java Swings and have interest in graphics designing, can change following method in my previous code. Changes can be like - menus and icons . Also my previous code was just a rough design , if any one can change it to better -it will be really appreciating. πŸ˜€

    private void submitButtonActionPerformed(java.awt.event.ActionEvent evt)
    Coming soon with sending and receiving messages thing. Please give some time πŸ˜€ By that time , if anyone can work on design of this "MainWindow". Also one more thing need to be done by that time is closing of "Sign In" window when "Main Window" opens.

    Thanks !
  • CEMember
    CEMember
    Hi every one ,
    Recently I have made few changes in Project structure , so following respective changes are done in my last to last post

    1. Image of Project Structure is updated .
    2. Code of following method is also changed. See last to last post for updates.
    private void submitButtonActionPerformed(java.awt.event.ActionEvent evt)
    3. A new J Frame class called as "MainWindow" is created. Its code is as follows at present. [Soon going to update :sshhh: ]
    /*
     * MainWindow.java
     *
     * Created on July 6, 2009, 9:49 PM
     */
    
    package com.crazyengineers.im.webpages;
    
    /**
     *
     * @author  cemember
     */
    public class MainWindow extends javax.swing.JFrame {
        
        /** Creates new form MainWindow */
        public MainWindow() {
            initComponents();
        }
        
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        // 
        private void initComponents() {
    
            TempLabel = new javax.swing.JLabel();
    
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    
            TempLabel.setFont(new java.awt.Font("Comic Sans MS", 0, 14));
            TempLabel.setForeground(new java.awt.Color(255, 0, 0));
            TempLabel.setText("Login Successful !!!");
    
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(71, 71, 71)
                    .addComponent(TempLabel)
                    .addContainerGap(84, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(103, 103, 103)
                    .addComponent(TempLabel)
                    .addContainerGap(355, Short.MAX_VALUE))
            );
    
            pack();
        }// 
        
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new MainWindow().setVisible(true);
                }
            });
        }
        
        // Variables declaration - do not modify
        private javax.swing.JLabel TempLabel;
        // End of variables declaration
        
    }
    
    MainWindow would appear as following at present :
    [​IMG]

    ---------------------------------------------------------
    Also one more thing need to be done by that time is closing of "Sign In" window when "Main Window" opens.
    This problem mentioned by me in my last post is solved now.

    PS: Coming soon with "Sending and Receiving messages" thing also. Please give some more time πŸ˜€ Again saying by that time , if anyone can work on design of this "MainWindow" class , it will be really appreciating.

    Thanks ! πŸ˜€
  • CEMember
    CEMember
    I have a question Mr xero Sir, if you are reading my this post by chance πŸ˜”. Do we need to maintain "session" for the logged in user or not? If yes, how we are supposed to do that, any ideas?

    Thanks for replying as soon as possible ! πŸ˜€
  • CEMember
    CEMember
    Would anyone reply here to my query or am I talking to myself on this so called FORUM ? πŸ˜€

    1 suggestion [Take it or ignore it -your wish πŸ˜€]:Never start a project thread when you cannot carry it. πŸ˜€
  • xero
    xero
    Hey guys,
    Sorry I've been out for quite a while now, and really sorry for leaving the thread just like that !!

    CEM, I really appreciate your hard work and time you are giving for the project and also sorry for not carrying out my "responsibilities" πŸ˜€.
    I'm just looking at the code and will tell you the way to maintain a session.
    PS: I prefer ignoring your comment !

    I'll just go through the thread from where I left, and will continue this thread.
  • CEMember
    CEMember
    xero
    Hey guys,
    Sorry I've been out for quite a while now, and really sorry for leaving the thread just like that !!

    CEM, I really appreciate your hard work and time you are giving for the project and also sorry for not carrying out my "responsibilities" πŸ˜€.
    I'm just looking at the code and will tell you the way to maintain a session.
    PS: I prefer ignoring your comment !

    I'll just go through the thread from where I left, and will continue this thread.
    Hey man, Thanks a lot for atleast your coming back words and regarding comment I guess better learn to take them πŸ˜‰ Ha , just kidding !
  • xero
    xero
    CEM, once you log in using XMPPConnection.login, you can disconnect using XMPPConnection.disconnect.
    Following is a sample snippet which can provide you a scenario to disconnect.

    addWindowListener(new WindowAdapter(){
    public void windowClosed(WindowEvent we) {
    try{
    con.disconnect();
    System.exit(0);
    }
    catch(Exception e){}
    }
    });

    So in the above code on closing a window I'm disconnecting the connection that I had established on application initialization. So that way you are maintaining a session between the XMPPConnections.login and XMPPConnection.disconnect

    Was this the info you were expecting?
  • CEMember
    CEMember
    Hey Sir,
    Thanks for the info. but I don't think so it will work because if you see my submit() method or your old code only, in that connection.disconnect(); statement was added in finally() block that means if I comment it, the connection should remain opened right? So no need of Window Listeners right but problem is I just want the logged in user's name and password values from my first page "LoginPage.java" in "ChatWindow.java" where sending and receiving messages code will start. Well, I somehow managed to get the Connection object there but still not getting username and password. Don't know going right way or not but still trying, will let you know if done.

    Please feel free to correct if going wrong.

    Thanks !
  • xero
    xero
    You can pass the username from the LoginPage.java to ChatWindow.java by passing them as parameters to constructor of MainWindow.java.

    MainWindow mainWindowFrame = null;
    try {
    String username = null, password = null;
    connection = new XMPPConnection("localhost");

    connection.connect();
    username = userNameTxtField.getText();
    System.out.println("Username : " + username);
    password = passwordTxtField.getText();
    System.out.println("Password : " + password);

    connection.login(username, password);
    // you can pass the credentials as the parameters
    // by simply passing them as parameter to constructor
    mainWindowFrame = new MainWindow(username, password);

    mainWindowFrame.setVisible(true);
    this.setVisible(false);

    } catch (XMPPException e) {
    messageDisplayLabel.setText("Invalid credentials !!");
    } finally {
    connection.disconnect();
    }

    Can this solve your problem ?
  • CEMember
    CEMember
    Hey! Man, thanks a lot, it worked though not the way I wanted πŸ˜‰ but still something is always better than nothing. Why this simple thing didn't striked my mind before.:sshhh:

    Just one problem I may face now, is login again with what username and password I will receive in my ChatWindow program to start sending and receiving messages. I was thinking if there could be any such way so that as soon as user logs in , his connection remains active throughout chatting until he signs out. Well, that is not current headache. Your thing worked. I will come up with sending and receiving thing soon. πŸ˜€

    Thanks a lot !

    [Update: Man, no need for thinking of maintaining connection alive. It is done now. Now I need not to add login code again in ChatWindow. πŸ˜€ ]
  • CEMember
    CEMember
    OK, Guys !

    Now few things I have done a step ahead more

    Updated Working scenario of CE-IM :

    Step 1: Login Window. User Logs in. Code is bit changed now for this class. Username ="Admin" and password ="password" at present.
    [​IMG]



    Step 2: Main Window opens showing list of all users added in the contact list of logged in user.[Right now contact is hardcoded. "cemember" -coding part need to be change later for this. ]

    [​IMG]

    Step 3: User clicks on the name of any contact added , a "ChatWindow" appears for the logged in user.

    [​IMG]

    Step 4: The added contact "cemember" at present logs in and chats through "Spark" right now.

    [​IMG]

    [​IMG]
    Step 5: A smooth conversation starts at present. πŸ˜€

    Appearance of chat window at "Admin's" end
    [​IMG]


    Appearance of chat window at "cemember's" end
    [​IMG]

    PS: Coding part in next post as this poor CE system allows only 20000 characters πŸ˜”
  • CEMember
    CEMember
    Updated Project Strcuture and Code -I :

    I am reposting whole thing again so as folllowers of this thread need not to go back to last posts.

    Project Structure is changed again as follows:
    [​IMG]

    Now Code for 3 classes at present
    1. LoginPage.java

    /*
     * LoginPage.java
     *
     * Created on June 27, 2009, 3:15 PM
     */
    package com.crazyengineers.im.authentication;
    import com.crazyengineers.im.webpages.MainWindow;
    import org.jivesoftware.smack.XMPPConnection;
    import org.jivesoftware.smack.XMPPException;
    /**
     *
     * @author  cemember
     */
    public class LoginPage extends javax.swing.JFrame {
        public static XMPPConnection connection = null;
     
        /** Creates new form LoginPage */
        public LoginPage() {
            initComponents();
        }
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        //                           
        private void initComponents() {
            jLabel1 = new javax.swing.JLabel();
            userNameLabel = new javax.swing.JLabel();
            userNameTxtField = new javax.swing.JTextField();
            passwordLabel = new javax.swing.JLabel();
            submitButton = new javax.swing.JButton();
            ImageLogo = new javax.swing.JLabel();
            headerLabel = new javax.swing.JLabel();
            passwordTxtField = new javax.swing.JPasswordField();
            messageDisplayLabel = new java.awt.Label();
            jLabel1.setText("jLabel1");
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            userNameLabel.setText("UserName");
            userNameTxtField.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    userNameTxtFieldActionPerformed(evt);
                }
            });
            passwordLabel.setText("Password");
            submitButton.setText("Sign In");
            submitButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    submitButtonActionPerformed(evt);
                }
            });
            ImageLogo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            ImageLogo.setIcon(new javax.swing.ImageIcon("G:\\PICTURES\\CE\\CELogo.png")); // NOI18N
            headerLabel.setFont(new java.awt.Font("Comic Sans MS", 1, 14));
            headerLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            headerLabel.setText("Instant Messenger");
            passwordTxtField.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    passwordTxtFieldActionPerformed(evt);
                }
            });
            messageDisplayLabel.setForeground(new java.awt.Color(255, 0, 0));
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(messageDisplayLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(userNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(passwordLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(passwordTxtField)
                                .addComponent(userNameTxtField, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGap(84, 84, 84)
                            .addComponent(submitButton))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(ImageLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGap(28, 28, 28)
                            .addComponent(headerLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap())
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(4, 4, 4)
                    .addComponent(ImageLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(headerLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(messageDisplayLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(1, 1, 1)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(userNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(userNameTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(passwordLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(passwordTxtField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(20, 20, 20)
                    .addComponent(submitButton)
                    .addContainerGap(78, Short.MAX_VALUE))
            );
            pack();
        }//                         
        private void userNameTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {                                                 
    }                                                
        [COLOR=navy]private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             [/COLOR]
    [COLOR=navy]   String username,password = null;[/COLOR]
    [COLOR=navy]   MainWindow mainWindowFrame = null;[/COLOR]
    [COLOR=navy]   try {[/COLOR]
     
    [COLOR=navy]       connection=new XMPPConnection("localhost");[/COLOR]
    [COLOR=navy]       connection.connect();[/COLOR]
    [COLOR=navy]       username=userNameTxtField.getText();[/COLOR]
    [COLOR=navy]       System.out.println("Username : " + username);[/COLOR]
    [COLOR=navy]       password=passwordTxtField.getText();[/COLOR]
    [COLOR=navy]       System.out.println("Password : " + password);[/COLOR]
    [COLOR=navy]       connection.login(username,password);[/COLOR]
    [COLOR=navy]       System.out.println("User logged in..");[/COLOR]
     
    [COLOR=navy]       mainWindowFrame = new MainWindow(username);[/COLOR]
    [COLOR=navy]       mainWindowFrame.setVisible(true);[/COLOR]
    [COLOR=navy]       this.setVisible(false);[/COLOR]
    [COLOR=navy]   } catch (XMPPException e) {[/COLOR]
    [COLOR=navy]       messageDisplayLabel.setText("Invalid credentials !!");[/COLOR]
    [COLOR=navy]       userNameTxtField.setText("");[/COLOR]
    [COLOR=navy]       passwordTxtField.setText("");[/COLOR]
    [COLOR=navy]   } finally {[/COLOR]
    [COLOR=navy]      // connection.disconnect();[/COLOR]
    [COLOR=navy]   }[/COLOR]
    [COLOR=navy]}[/COLOR]                                            
        private void passwordTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {                                                 
            messageDisplayLabel.setText("");
    }                                                
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new LoginPage().setVisible(true);
                }
            });
        }
        // Variables declaration - do not modify                     
        private javax.swing.JLabel ImageLogo;
        private javax.swing.JLabel headerLabel;
        private javax.swing.JLabel jLabel1;
        private java.awt.Label messageDisplayLabel;
        private javax.swing.JLabel passwordLabel;
        private javax.swing.JPasswordField passwordTxtField;
        private javax.swing.JButton submitButton;
        private javax.swing.JLabel userNameLabel;
        private javax.swing.JTextField userNameTxtField;
        // End of variables declaration                   
     
       }
    
    2. MainWindow.java

    /*
    * MainWindow.java
    *
    * Created on July 6, 2009, 9:49 PM
    */
    package com.crazyengineers.im.webpages;
    /**
    *
    * @author cemember
    */
    public class MainWindow extends javax.swing.JFrame {
    private String username;
     
    /** Creates new form MainWindow */
    public MainWindow(String username) {
    this.username=username;
    initComponents();
    }
     
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    */
    //  
    private void initComponents() {
    TempLabel = new javax.swing.JLabel();
    recipient = new javax.swing.JLabel();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    TempLabel.setFont(new java.awt.Font("Comic Sans MS", 0, 14));
    TempLabel.setForeground(new java.awt.Color(255, 0, 0));
    TempLabel.setText("Login Successful !!!");
    recipient.setText("cemember");
    recipient.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    recipientMouseClicked(evt);
    }
    });
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(71, 71, 71)
    .addComponent(TempLabel))
    .addGroup(layout.createSequentialGroup()
    .addGap(24, 24, 24)
    .addComponent(recipient, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addContainerGap(84, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(103, 103, 103)
    .addComponent(TempLabel)
    .addGap(30, 30, 30)
    .addComponent(recipient, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(264, Short.MAX_VALUE))
    );
    pack();
    }//  
    private void recipientMouseClicked(java.awt.event.MouseEvent evt) { 
     
    ChatWindow chatWindowFrame = new ChatWindow(this.username);
    chatWindowFrame.setVisible(true);
    //chatWindowFrame.getMessageTextArea().setText(tempLabel2.getText());
    this.setVisible(false);
     
    } 
     
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    //new MainWindow(this.getUsername(),this.getPassword()).setVisible(true);
    }
    });
    }
     
    // Variables declaration - do not modify 
    private javax.swing.JLabel TempLabel;
    private javax.swing.JLabel recipient;
    // End of variables declaration 
    public javax.swing.JLabel getRecipient() {
    return recipient;
    }
    public void setRecipient(javax.swing.JLabel recipient) {
    this.recipient = recipient;
    }
     
     
    }
    
    3. ChatWindow.java
    Code in next post....
    PS: Coding part in next post as this poor CE system allows only 20000 characters πŸ˜”
  • CEMember
    CEMember
    Updated Project Strcuture and Code -II :

    3. ChatWindow.java

    /*
     * ChatWindow.java
     *
     * Created on July 6, 2009, 11:11 PM
     */
    package com.crazyengineers.im.webpages;
    import com.crazyengineers.im.authentication.LoginPage;
    import org.jivesoftware.smack.Chat;
    import org.jivesoftware.smack.MessageListener;
    import org.jivesoftware.smack.XMPPException;
    import org.jivesoftware.smack.packet.Message;
    /**
     *
     * @author  cemember
     */
    public class ChatWindow extends javax.swing.JFrame {
        private String username;
       StringBuilder chatAreaText =new StringBuilder("");
        /** Creates new form ChatWindow */
        public ChatWindow(String username) {
            this.username=username;
            initComponents();
        }
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        // 
        private void initComponents() {
            jScrollPane1 = new javax.swing.JScrollPane();
            MessageTextArea = new javax.swing.JTextArea();
            sendButton = new javax.swing.JButton();
            jScrollPane2 = new javax.swing.JScrollPane();
            ChatTextArea = new javax.swing.JTextArea();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            MessageTextArea.setColumns(20);
            MessageTextArea.setRows(5);
            jScrollPane1.setViewportView(MessageTextArea);
            sendButton.setText("Send");
            sendButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    sendButtonActionPerformed(evt);
                }
            });
            ChatTextArea.setColumns(20);
            ChatTextArea.setRows(5);
            jScrollPane2.setViewportView(ChatTextArea);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(sendButton, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap())
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
                    .addGap(13, 13, 13)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(sendButton, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE))
                    .addContainerGap())
            );
            pack();
        }// 
        private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
            boolean closeChat = false;
            LoginPage loginPage = null;
            MainWindow mainWindowFrame = null;
            String recipient = null;
            try {
                mainWindowFrame = new MainWindow(this.username);
                loginPage = new LoginPage();
               // System.out.println("Connection : " + LoginPage.connection);
              //  System.out.println("Username : " + this.username);
                recipient = mainWindowFrame.getRecipient().getText();
                System.out.println("Recipient : " + recipient);
     
                if (recipient.equals("")) {
                    recipient = username + "@localhost";
                } else {
                    recipient += "@localhost";
                }
                String message;
                Chat chat = LoginPage.connection.getChatManager().createChat(recipient,new MessageListener() {
                            public void processMessage(Chat chat, Message message) {
                                chatAreaText.append("\n" + message.getFrom() + ": " + message.getBody());
                                ChatTextArea.setText(chatAreaText.toString());
                            }
                        });
     
                   message = MessageTextArea.getText();
                    if (message.equals("close")) {
                        closeChat = true;
                    } else {
                        chat.sendMessage(message.toString());
                        MessageTextArea.setText("");
                        chatAreaText.append("\n" + this.username + ": " + message);
                        ChatTextArea.setText(chatAreaText.toString());
                    }
     
     
              this.setVisible(true);
            } catch (XMPPException e) {
                System.out.println("Cannot find connections");
            }  finally {
              LoginPage.connection.disconnect();
            }
        }                                          
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                }
            });
        }
        // Variables declaration - do not modify
        private javax.swing.JTextArea ChatTextArea;
        private javax.swing.JTextArea MessageTextArea;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JScrollPane jScrollPane2;
        private javax.swing.JButton sendButton;
        // End of variables declaration
    }
    
    Now when above LoginPage.java is made to run, this chatting thing works in steps mentioned in the starting of #-Link-Snipped-# post.

    [ PS: Ah ! Damn tired even sleepy. Rest of the things I will post later. :sleeping: Good night ! Grant excuse if any mistakes made in all posts while typing]

    Thanks ! Feel free to modify the code and making it better. Comments most welcome.
  • CEMember
    CEMember
    *Surprising * No comments yet. Anyways , xero Sir Please check if I am on right track or not. I guess if above thing is ok, then next thing we can do is

    1. Designing of "MainWindow" -showing list of online members in green and offline if grey. Ading other icons and menu things. Everyone feel free to add ideas and icons or images for it.
    2. Making chatting possible without using Spark at receiver's end. xero, Please give tips for this -how to proceed.

    PS: All 3 java classes above are just roughly made so programming experts can find some of their time to optimize them to the best though they will go more changes in future.

    Thanks ! πŸ˜€
  • NIMISH PRABHU
    NIMISH PRABHU
    i am doing second year computers
    and all i could understand[things familiar to me] in first post was "Java" "Eclipse" "OO"
    can someone tell me when i will be taught to make softwares of my own?
    is eclipse used for the same?
    i have written small small java programs for applets and addition multiplication etc in eclipse
    but dont know wat exactly is required for making full softwares
    will i be taught about it in my college? or it should be learned from net or reading certain books?
  • shalini_goel14
    shalini_goel14
    NIMISH PRABHU
    i am doing second year computers
    and all i could understand[things familiar to me] in first post was "Java" "Eclipse" "OO"
    can someone tell me when i will be taught to make softwares of my own?
    is eclipse used for the same?
    i have written small small java programs for applets and addition multiplication etc in eclipse
    but dont know wat exactly is required for making full softwares
    will i be taught about it in my college? or it should be learned from net or reading certain books?
    Ask your queries in separate thread. Don't SPAM this thread. Also SMS language is not allowed here.

    Mods - I guess this post is not made for this thread. 😐
  • xero
    xero
    CEM you are going good πŸ˜€

    With the existing progress have you tried chatting without Spark Client. You can proceed with the minimum requirements that you'll need to perform that operation. I've not looked at the new API specs provided, although in older versions it was bit sophisticated and it involved filtering at packet level which was pretty tedious. If possible try to go through the new API and search for other lesser sophisticated procedures to perform that operation.
    I think we can ignore the status part right now and focus on providing a basic chat operation between two desktop agents ie. without Spark.

    Let me know if you are stuck? If you want to know the details of the implementation that i just mentioned, its better to do over IM. So in that case PM me your IM id (yahoo, skype or gtalk) I'll share you the implementation and will give you a brief about it.

    For a basic IM implementation it shouldn't take more than 5 classes πŸ˜€. So try to keep it as simple as possible. In swings try to ignore the AWT classes as much as possible, since these are platform specific implementations. Use the javax.swing package instead.

    Till then, have fun !!
  • CEMember
    CEMember
    Hey I don't know how to proceed without using Spark ? πŸ˜” That's why I asked you. Guidance Please if possible. I guess I have not made anything complicated till now. It is basic approach to keep every windo'w code separately though as soon as this project will progress , things may change accordingly.
  • CEMember
    CEMember
    Ok Man, I tried it bu just creating a replica of current project and then running two windows in my same system "without using Spark" anymore. The conversation as per me and current code, it went fine but I still feel some gotcha is there * scratching my head * Not sure πŸ˜•

    See the conversations window at
    Sender's end : "Admin"

    [​IMG]


    Receiver's end : "CEMember"

    [​IMG]

    Check, if this is correct way of doing or not? I guess now I need to get my hands good on "Swings" and more on Smack API. πŸ˜”
    So I guess I should put a break for this here. What say xero ? Suggestions Please !
  • xero
    xero
    CEM, that's a fantastic job, well done πŸ˜€
    By the way, what did you meant by gotcha in your last reply?

    Although there might be a lot of issues still unresolved with the current code, however the current status is a marvelous check point.

    Eg. In the current code, (btw, correct me if I'm wrong) if one user wants to chat with another user, both the users has to open the chat window. There are not listeners at either ends which would sense incoming message and pop up a window !

    PS: Scratching your head is just gonna make you bald, so chill out mate you did good

    I may not be available on Sunday. So i'll be back on this from Monday.

    Happy weekend !
  • CEMember
    CEMember
    xero
    CEM, that's a fantastic job, well done πŸ˜€
    By the way, what did you meant by gotcha in your last reply?

    Although there might be a lot of issues still unresolved with the current code, however the current status is a marvelous check point.

    Eg. In the current code, (btw, correct me if I'm wrong) if one user wants to chat with another user, both the users has to open the chat window. There are not listeners at either ends which would sense incoming message and pop up a window !
    Hey ! Many thanks man πŸ˜€.
    "gotcha" means mistakes that one is not awared of but know it is there.

    Yes, you are right - I was thinking if I can do something like that opening a window at the receiver's end.I guess it would be something like handling offline message receiving thing[Not sure-Correct me if wrong]. As you mentioned adding listeners and stuff can do so, I need to look into it -how to do all that.

    Thanks for the guidance ! 😁
  • safwan
    safwan
    Any help for SQL and vb .NET i am ready to help .
  • Ashraf HZ
    Ashraf HZ
    I don't mean to derail discussions, but have any of you put into thought about socket programming with VB or C#? Creating messenger applications look a lot easy with that.. though with very basic capabilities. Useful for the programming newbies like me πŸ˜‰

    But, those who are deep into the Java and Smack in this thread are encouraged to continue development πŸ˜€
  • Manish Goyal
    Manish Goyal
    I would like to continue with this project

    Is there anyone who would like to be work with me?
    It would be great if previous team members come back

    I will reply here soon once i set up environment required for this ..

    Waiting for replies
  • xheavenlyx
    xheavenlyx
    After CEMember and xero left, this project has stalled! They made amazing progress...what happened??
  • xheavenlyx
    xheavenlyx
    The CE IM project will be closed. As Biggie as said we will be concentrating on smaller projects that should ship as soon as possible. Problem's that need solving and solutions that help.
  • Ashraf HZ
    Ashraf HZ
    Projects are downsizing eh.. πŸ˜›
  • xheavenlyx
    xheavenlyx
    Well, downsizing sounds like firing people. Housecleaning is a better word.

    And nice to see you too πŸ˜€
  • xero
    xero
    hey.. it been quite a long time since i last visited.. but no matter what, i still can't get over this project. Although, CEMember did a fantastic job with its progress.. m planning to give it a shot again πŸ˜€
  • xero
    xero
    so.. in continuation to what i've in mind this is time.. is a web page analogous to meebo.com, but more CE-centric, with messaging and lot of other features. I'll begin a new thread with some new name 😁
  • xheavenlyx
    xheavenlyx
    You know frankly, I don't want to see another messenger. We all are already so connected. Blackberry, facebook, SMS, Google Talk, Twitter, Google+, Facebook chat, yahoo, msn, blah blah blah the list goes on.

    We should be working towards having face to face meetups in locations near us. Human interaction is slowly going away. It's still there in India but where I live, we are connected 24/6. Enough now.
  • Jeffrey Arulraj
    Jeffrey Arulraj
    yup my pal #-Link-Snipped-# how many CEans are in your FB friend list other than Some MODS and top regular posters
  • Jeffrey Arulraj
    Jeffrey Arulraj
    I like this idea personally so will extend my full support to it The_Big_K gives a green flag to it
  • xero
    xero
    #-Link-Snipped-#, while i appreciate your concern on 'yet another chat mechanism' & i sincerely hope you must have some plan in action for efficient vis-à-vis gatherings; my sole objective is learning using practical examples and we do have lot of enthusiasts who will be willing to learn from it. Even i'm learning technologies required and its fun πŸ˜€
    Thus, lets not argue on whether we want it or not and focus on learning. I hope you understand my intent.
  • Jeffrey Arulraj
    Jeffrey Arulraj
    this is a TECH DISCUSSION FORUM so kindly let us keep the CHAT thing completely and wholy technical

    That is my only concern
  • Ashraf HZ
    Ashraf HZ
    Hi xero, please proceed in starting a new thread for your ideas. I hope you are able to take the lead on it, get together a few CE members and steer the discussions πŸ˜€

    Hi xhx, lets find a way to set up gatherings remotely (e.g via google hangouts), at least on some weekends or so..
  • xero
    xero
    from what i've experienced, from past projects, a long term project dies down in the middle, although significant learning happens, but still... its stuck in halfway. i'm wondering, how about a 24 hr code marathon? This makes it a ONE day exercise, full zeal, and final product in one day.. HEAD TO TOE. These days frameworks are stable and reliable to deliver products in crazy timelines. So how about such marathons?

    #-Link-Snipped-#, what's your take?
  • Kaustubh Katdare
    Kaustubh Katdare
    We sure can host a marathon. I need to know the details and few volunteers who can take this forward. CE Messenger, however is a big product. Without deviating from the main topic; can we think of something smaller and 'achievable'?

You are reading an archived discussion.

Related Posts

Hi all, I have a requirement in a web application developed using Struts2.I have to generate PDF/RTF reports using XML and XSLFO. I have generated PDF but in RTF its...
I am a PHP Developer , i want to integrate the Ebay site to another site ie login , product display , product purchase ,checkout completion and so on ,...
hi guys. i have an xls sheet in openoffice.org. i'm workin on a small project and i need to convert this sheet into a mysql database. i see that openoffice...
Hello, I seek advice, i am going to the 3rd semester of my course & i have been asked to choose a free elective, i am confused to choose amongst...
i need some design notes on foot print power generation so pls help me out