Question

I'm building an IM program using java IO, and I have an Object called Message. what field do you recommend me to add to Message Class? I did the folowing:

 public class Message implements Serializable {

    static private final long serialVersionUID=12525452;

    enum commands{
    LEAVE, 
    ONLINELISTREQUEST,
    SENT,
    DELIVERED,
    READ; 
    }

    enum types{
    TEXT,
    VEDIO,
    PICTURE,
    AUDIO,
    COMMAND,
    //...... what to add?? 
    }

    // fields..
    private   String From;
    private   String To;
    private   String Body;
    private   int type; 
    private   String url;
    private   int command; 
    //what to add??
Was it helpful?

Solution

ALso have variable as STATE which will be having values as:-

SEEN, SENT, etc..

This will help in tracking of message and also launch a threads which will keep on checking whether messages which don't have status as SENT/ RECEIVED just resend them

OTHER TIPS

Just use the teachings of Object Oriented concepts. A class should have attributes that are really properties of the entity represented by that class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top