Need Help in creating Text Chat site . . .
Page 1 of 112 Replies - 789 Views - Last Post: 12 July 2010 - 08:20 PM
#1
Need Help in creating Text Chat site . . .
Posted 09 July 2010 - 09:01 AM
I am creating TextChat site .. on java Servlet .. I want to know the mechanism of identifying each user to forward message updates between each other in that perticular chat room.
whether it i by knowing there ip-adress OR how.
THANKS to all Helpers ....
Replies To: Need Help in creating Text Chat site . . .
#2
Re: Need Help in creating Text Chat site . . .
Posted 09 July 2010 - 09:07 AM
#3
Re: Need Help in creating Text Chat site . . .
Posted 09 July 2010 - 09:07 AM
You could also consider setting a cookie that identifies the user and chat room.
-Frinny
This post has been edited by Frinavale: 09 July 2010 - 09:08 AM
#4
Re: Need Help in creating Text Chat site . . .
Posted 09 July 2010 - 04:31 PM
macosxnerd101, on 09 July 2010 - 08:07 AM, said:
I've recently studied network programming course .... in socket programming ther is problem that it won't work in internet environment ... beacause if we inthis we know the externet ip address of network/client but to reach to client system we have to know his system ip-address. so i this will not work in intenet environment according to my knowledg .. may b there i solution to this.
#5
Re: Need Help in creating Text Chat site . . .
Posted 09 July 2010 - 04:38 PM
Frinavale, on 09 July 2010 - 08:07 AM, said:
You could also consider setting a cookie that identifies the user and chat room.
-Frinny
lets discuss your idea ....
i think i m right that sessions are at user end ... i mean at user's/client PC .... so one way to identify is that i send message update to all clients with some checking variable ... and at user end it first check from cookies the type of user ... if this msg if for his/her then displa to user otherwise discard it.
But i think this is not an efficient way to do this .... i want that message is sent from to just only required person' not to any extra.
<sorry my english may not that much goog ... but i think understandable
#6
Re: Need Help in creating Text Chat site . . .
Posted 09 July 2010 - 04:45 PM
#7
Re: Need Help in creating Text Chat site . . .
Posted 09 July 2010 - 04:50 PM
#8
Re: Need Help in creating Text Chat site . . .
Posted 10 July 2010 - 08:45 AM
macosxnerd101, on 09 July 2010 - 03:45 PM, said:
U mean when user generate query to server for update messages then server will response and send all messages to user. yes it's quite easy way ... but i want that server sends update automatically, not on request.
#9
Re: Need Help in creating Text Chat site . . .
Posted 10 July 2010 - 09:16 AM
PsychoCoder, on 09 July 2010 - 03:50 PM, said:
Thanks you very much .... plz some more help .. i think you lead me to the solution.
Ok Now i understand .. let suppose i use session for it to keep recored of users in meeting ... e.g. there ID<PrimaryKey>, userType, etc ... and use this to identify user right ... but again question is that from this recored which thing is acting as to identify user destination(that where to send data of this XYZ-user) e.g. whether i use IP-Address respective to each user in this DB to identify them or any thing else ... !!
I MEANS IN SESSIONS WHICH RECORD IS ACTING AS DESTINATION POINT OF ANY USER ??
In my mind this question is like this,
I have craeted chating page, And there are offcours many users that use this page at same time like there are many instances of this page. Now when server sends update to user's then how it know that which page is which user. (may be my logic is also wrong to do this)
This post has been edited by khurram.1987: 10 July 2010 - 09:18 AM
#10
Re: Need Help in creating Text Chat site . . .
Posted 10 July 2010 - 10:07 AM
khurram.1987, on 10 July 2010 - 11:45 AM, said:
macosxnerd101, on 09 July 2010 - 03:45 PM, said:
U mean when user generate query to server for update messages then server will response and send all messages to user. yes it's quite easy way ... but i want that server sends update automatically, not on request.
I think you can use something like AJAX polling to force a refresh, which will cause query, and therefore an update.
Quote
I think you need to determine a couple things here- which users are online, and what chatrooms they are a part of. So start with your database design. You obviously need a users table, a users_online table, and a chatroom table. If you set up users as the FK in the chatroom table, with ID as the PK, it should just be a matter of querying and joining.
As for the destination part, this is more abstracted in many conventional web languages. You don't need to know the IP address or where to send the messages if you are using something like PHP. If you are using a Java Client/Server model, for example, then you may need more information. I guess the next question is- what language do you want to use?
This post has been edited by macosxnerd101: 10 July 2010 - 10:08 AM
#11
Re: Need Help in creating Text Chat site . . .
Posted 12 July 2010 - 03:13 AM
macosxnerd101, on 10 July 2010 - 09:07 AM, said:
khurram.1987, on 10 July 2010 - 11:45 AM, said:
macosxnerd101, on 09 July 2010 - 03:45 PM, said:
U mean when user generate query to server for update messages then server will response and send all messages to user. yes it's quite easy way ... but i want that server sends update automatically, not on request.
I think you can use something like AJAX polling to force a refresh, which will cause query, and therefore an update.
Quote
I think you need to determine a couple things here- which users are online, and what chatrooms they are a part of. So start with your database design. You obviously need a users table, a users_online table, and a chatroom table. If you set up users as the FK in the chatroom table, with ID as the PK, it should just be a matter of querying and joining.
As for the destination part, this is more abstracted in many conventional web languages. You don't need to know the IP address or where to send the messages if you are using something like PHP. If you are using a Java Client/Server model, for example, then you may need more information. I guess the next question is- what language do you want to use?
THANKS
I use Java Servlet for back end i means for core functionality and JSP for front end such that form/user side.
#12
Re: Need Help in creating Text Chat site . . .
Posted 12 July 2010 - 08:17 AM
khurram.1987, on 10 July 2010 - 03:16 PM, said:
I'm just going to elaborate a little on PsychoCoder's answer...
Session exists on the server. It is a place where you can store information while the user is actively using you website. It is available to all pages within your website so it is an excellent way to pass data between web pages as well as a being a great way to retain (persist) data between requests to the web page.
Session exists on the web server, but it needs a way to associate the user's web browser with the user's Session. Some sort of session identifier is given to the user's browser. Typically this identifier is stored as a cookie but I have seen solutions that use cookieless session identifiers by storing the identifier in the URL/QueryString. Using cookieless session is not advisable in most situations because if a user were to copy the URL and pass it on to another person, the other person will be able to access the first person's session.
khurram.1987, on 10 July 2010 - 03:16 PM, said:
I MEANS IN SESSIONS WHICH RECORD IS ACTING AS DESTINATION POINT OF ANY USER ??
You should probably create a class that represents the user.
This class will have members like the user-id, user-type, current-chat-room-id, last connection date/time. When the user logs in you will create an instance of this class and store it in session. You will retrieve this object from session every time the browser that the user is using sends a request to your website. This way you can tell who the user is, what type of user they are, what chat room they are currently connected to, when the user last connected to the web page etc.
As for the chat itself...well you need a way for users to connect to a "chat" and to retrieve information from the "chat" when it is available. Therefore, you will probably want a Chat class to manage a chat as well. The chat is going to have to store data somewhere in order for people to see what was said. You could store it in a database, or a text file, or an XML file...or if you don't need to keep a history of the chat you could just have the conversation exist in memory (session......) Just don't let the conversation grow too much or you could run into issues (so you'll have to delete old messages to make room for new messages). It's probably easier to use a file instead of memory
khurram.1987, on 10 July 2010 - 03:16 PM, said:
I have created chatting page, And there are of course many users that use this page at same time like there are many instances of this page. Now when server sends update to user's then how it know that which page is which user. (may be my logic is also wrong to do this)
The server cannot send information to the user's browser unless the user's browser is connected to the server. The browser does not maintain a connection at all times.
Websites operate in a disconnected environment:
- the web browser sends a request to the server (connects to the server),
- the server does some processing and sends a response to the browser
- the browser disconnects from the server
You cannot send information to the web browser if the web browser does not first ask for the information.
This is why the usage of sockets was mentioned earlier in the thread...sockets allow you to "push" data to the connected client when the data is available; however, implementing a server-push application can get complicated especially when you are using a web browser...these types of applications would require a client-application, that runs in the web browser, be developed using a language that can use sockets. Some languages that let you implement an application that runs in the web browser are Flash, Silverlight, and probably a Java application that can run in the web browser: an applet (I thought these were being phased out though...it's been a long time since I've used Java) Right now HTML, which is what your website is being built with, does not have sockets available. This is why you, in order to implement a server push application, you would need to develop an application that runs within the browser instead of a website. HTML 5 is supposed to include sockets... but it's still in the mix.
So, since you aren't going to use sockets, you need to add a feature to the web page that will cause it to "poll" for data periodically. This might not be very clear so I'll reword it: you need to add a feature that will cause to page to send a request to the server to get any updated chat data. This feature will probably be a Javascript "timer" of some sort that submits the page to the server every so often to check for new data.
-Frinny
This post has been edited by Frinavale: 13 July 2010 - 06:18 AM
#13
Re: Need Help in creating Text Chat site . . .
Posted 12 July 2010 - 08:20 PM
NOW ITS MUCH CLEAR IN MIND.
THANKS AGAIN
This post has been edited by khurram.1987: 12 July 2010 - 08:22 PM
|
|

New Topic/Question
Reply



MultiQuote







|