Page 1 of 1

Chat applet

Posted: Sun May 09, 2004 3:51 pm
by Neo
I was thinking of a Chat applet in Java. But can't find the first step to doing something like this.
Does anyone have any experience here? Which classes do you have to use? URL, Sockets, Datagrams??
As I said I have no idea where to start (I tried getting some existing projs but they are way too complicated)
Also considering that I get one working how do i manage to get my host to keep it(the server part) running always? or is that un-necessary?

Re:Chat applet

Posted: Mon May 10, 2004 5:48 am
by frth
have you ever tried sth simple ? a mud client ?
no gui .. only one client, only one server
asynchronous input/output, bidirectional
no protocols specified

http://www.topmudsites.com/

Re:Chat applet

Posted: Mon May 10, 2004 1:20 pm
by Neo
Err... What was that all about? MUD?
Anybody have any experience with some sort of a JAVA proj involving bidirectional commn?

Re:Chat applet

Posted: Tue May 11, 2004 11:51 am
by Neo
What kind of methods does a chat applet have to use implement bi-directional communication? or is there some other protocol other than HTTP (TCP/IP) for this? I need a stream-oriented protocol (I think) to do this, isn't that so?
How can commn. (like Instant Messengers,chat sites) be accomplished?
or am i wandering off?

Re:Chat applet

Posted: Tue May 11, 2004 1:23 pm
by distantvoices
Here:
www.distantvoices.org/download/javachat.zip

Mark: my copyright is upon it. some of the identifiers as well as all the comments are in german.

HtH

Re:Chat applet

Posted: Thu May 13, 2004 12:25 am
by kseutns
java graphics are complex;
instant messengers do not use java;
more often than we would like it to,
there are more than one ways to accomplish things;
there are classes that do not cooperate with each other,
or whose coordination becomes strenuous over time;
yet, a project evolves;
it never reaches its final stage,
it is never mature.
despite what we wish for,
we might engage in sth that will not work after a month,
or sth that could resemble life the following morning

- telnet gaia 13
Trying 147.52.16.45...
Connected to gaia.csd.uch.gr.
Escape character is '^]'.
Thu May 13 09:18:04 2004
Connection closed by foreign host.
-

this is a local server reporting time
can you rewrite it in java ?
replace telnet as the client ?
once u do that, it will be time for
distributed systems to come into play

Re:Chat applet

Posted: Thu May 13, 2004 2:58 pm
by Neo
Ok I hope this list of steps will help you guys understand where i am wrong. (I tried going through the example provided by infinity but can't understand it much because of the German)
Anyway here is what i think is the procedure and my questions ateach step...(BTW this is for a general room chat not personal client to client chat, I might try that after this works)
Server Side
1) Get the applet to execute (how all i have is a cpanel interface)
2) Listens for client connections
3) On receiving a connect from the client applet it spawns a thread and creates a output and input stream with the new socket from the client to itself.
4) Just keep outputting the input stream to the other clients.
5) Keep checking for new clients

Client Side
1) connect to the server page with the chat applet and load it.
2) create a input and output stream to the server using the new socket
3) send any data that the client sends to the server
4) display any data that is sent by the server, in the general room textarea.

So what all is wrong with the procedure outlined above? Any other hints?

Re:Chat applet

Posted: Thu May 13, 2004 9:35 pm
by zdtn
what mplayer win32 gui being experimental suggests ? that it is an application tied up to the command line user interface; in your case, makes debugging difficult. some jFpanel might be eccentric enough to prevent any output from reaching your screen, or some button might, just as well, be sleeping

alone ss.accept() - where ss a ServerSocket - is enough for bringing the server into a halt, if a client does not complete the connection; what is the timeout period for the above operation ? is there any amount of critical code, that would leave the system in inconsistent state ?

even streams can prove fatal; many tend to buffer output; there are byte streams and character streams; there are abstract classes! data streams that do not refresh their state, when you explicitly tell them to, or whose objects need to implement some serializable inteface

what happens when two threads attempt to read from the same stream ? if they try to write in the same socket, is there some kind of locking mechanism ? how much can they write, till they have to stop and wait for the other end to read it ? will they wait or just skip, and go to the next socket ? what guarantee is there that messages will be delivered in order, that an answer will not arrive before a question ? how many threads are assigned per socket ?

it wouldnt hurt if you mentioned which classes you've been using either.. how does the server behave with third-party clients ? can your applet connect to an arbitrary non-java server ? is the number of clients fixed, or can flunctuate exceeding the current java virtual machine's max number of threads ? can a client disconnect, and reconnect ? connect to multiple survers at the same time ? join more than one chat rooms ? killing a thread has any side effects ?

if ever come through that minefield alive, i have a perfect german-to-hindu dictionary !

http://www.loc.gov/standards/iso639-2/englangn.html

Re:Chat applet

Posted: Fri May 14, 2004 12:49 pm
by Neo
One confused individual that left me ???. Does anyone have any ideas what that was all about, some easier explanation maybe? and whats that about a german to "hindu??" dictionary?
BTW I haven't implemented anything as yet i'm still in design.