9 Replies - 927 Views - Last Post: 04 August 2009 - 02:12 PM Rate Topic: -----

#1 elibengigi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 04-August 09

Programmin a chat

Post icon  Posted 04 August 2009 - 03:56 AM

We do a project which is plug-in of built-in-chat on websites. We are working with a database in order to store all the details of the chat users . We did all technical stuff of creating the DB and reading from it etc. but we encounter a big problem when we try to send a message from user A to user B . Actually we know how to send the msg from user A but we do not know how can user B gets it . How does he aware of getting a new msg ? and how does we find user B ? via IP , url or something ? because if so we don't know how to do it.
We will be happy to hear suggestions such as Technologies which solve the problem or another way to solve it.
Thank a lot in advance.
Eli

Is This A Good Question/Topic? 0
  • +

Replies To: Programmin a chat

#2 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 291
  • View blog
  • Posts: 1,900
  • Joined: 25-October 06

Re: Programmin a chat

Posted 04 August 2009 - 04:05 AM

View Postelibengigi, on 4 Aug, 2009 - 09:56 AM, said:

We do a project which is plug-in of built-in-chat on websites. We are working with a database in order to store all the details of the chat users . We did all technical stuff of creating the DB and reading from it etc. but we encounter a big problem when we try to send a message from user A to user B . Actually we know how to send the msg from user A but we do not know how can user B gets it . How does he aware of getting a new msg ? and how does we find user B ? via IP , url or something ? because if so we don't know how to do it.
We will be happy to hear suggestions such as Technologies which solve the problem or another way to solve it.
Thank a lot in advance.
Eli

how do users join the chat? e.g. send you a UDP datagram ? if so you make a note of datagram source IP in your database. then use it to send messages to the user.

This post has been edited by horace: 04 August 2009 - 04:06 AM

Was This Post Helpful? 0
  • +
  • -

#3 elibengigi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 04-August 09

Re: Programmin a chat

Posted 04 August 2009 - 05:10 AM

View Posthorace, on 4 Aug, 2009 - 03:05 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 09:56 AM, said:

We do a project which is plug-in of built-in-chat on websites. We are working with a database in order to store all the details of the chat users . We did all technical stuff of creating the DB and reading from it etc. but we encounter a big problem when we try to send a message from user A to user B . Actually we know how to send the msg from user A but we do not know how can user B gets it . How does he aware of getting a new msg ? and how does we find user B ? via IP , url or something ? because if so we don't know how to do it.
We will be happy to hear suggestions such as Technologies which solve the problem or another way to solve it.
Thank a lot in advance.
Eli

how do users join the chat? e.g. send you a UDP datagram ? if so you make a note of datagram source IP in your database. then use it to send messages to the user.


Thank you very much Hoarce . But i would be glad if you will be able to be more specific . I mean - what is the exact way you suggest to apply your idea : using threads ? sockets ? Does the JMS technolgy can be helpful?
Thank you again
Was This Post Helpful? 0
  • +
  • -

#4 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 291
  • View blog
  • Posts: 1,900
  • Joined: 25-October 06

Re: Programmin a chat

Posted 04 August 2009 - 05:25 AM

View Postelibengigi, on 4 Aug, 2009 - 11:10 AM, said:

View Posthorace, on 4 Aug, 2009 - 03:05 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 09:56 AM, said:

We do a project which is plug-in of built-in-chat on websites. We are working with a database in order to store all the details of the chat users . We did all technical stuff of creating the DB and reading from it etc. but we encounter a big problem when we try to send a message from user A to user B . Actually we know how to send the msg from user A but we do not know how can user B gets it . How does he aware of getting a new msg ? and how does we find user B ? via IP , url or something ? because if so we don't know how to do it.
We will be happy to hear suggestions such as Technologies which solve the problem or another way to solve it.
Thank a lot in advance.
Eli

how do users join the chat? e.g. send you a UDP datagram ? if so you make a note of datagram source IP in your database. then use it to send messages to the user.


Thank you very much Hoarce . But i would be glad if you will be able to be more specific . I mean - what is the exact way you suggest to apply your idea : using threads ? sockets ? Does the JMS technolgy can be helpful?
Thank you again

it depends on how the chat operates - you can use TCP or UDP
(1) have a main thread with a TCP ServerSocket waiting for chat clients to connect
(2) when a client connects via TCP create a new thread to process the chat

it the intention for all clients to chat to all others, e.g. a message received is sent to all other clients (fairly simple), or would a client select someone to chat too (fairly complex)

This post has been edited by horace: 04 August 2009 - 05:26 AM

Was This Post Helpful? 0
  • +
  • -

#5 elibengigi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 04-August 09

Re: Programmin a chat

Posted 04 August 2009 - 05:54 AM

View Posthorace, on 4 Aug, 2009 - 04:25 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 11:10 AM, said:

View Posthorace, on 4 Aug, 2009 - 03:05 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 09:56 AM, said:

We do a project which is plug-in of built-in-chat on websites. We are working with a database in order to store all the details of the chat users . We did all technical stuff of creating the DB and reading from it etc. but we encounter a big problem when we try to send a message from user A to user B . Actually we know how to send the msg from user A but we do not know how can user B gets it . How does he aware of getting a new msg ? and how does we find user B ? via IP , url or something ? because if so we don't know how to do it.
We will be happy to hear suggestions such as Technologies which solve the problem or another way to solve it.
Thank a lot in advance.
Eli

how do users join the chat? e.g. send you a UDP datagram ? if so you make a note of datagram source IP in your database. then use it to send messages to the user.


Thank you very much Hoarce . But i would be glad if you will be able to be more specific . I mean - what is the exact way you suggest to apply your idea : using threads ? sockets ? Does the JMS technolgy can be helpful?
Thank you again

it depends on how the chat operates - you can use TCP or UDP
(1) have a main thread with a TCP ServerSocket waiting for chat clients to connect
(2) when a client connects via TCP create a new thread to process the chat

it the intention for all clients to chat to all others, e.g. a message received is sent to all other clients (fairly simple), or would a client select someone to chat too (fairly complex)


So , you say that using threads and sockets is the best method? What's about its overhead? for instance if there are many users it is not so efficient to create a thread for each. am i right?

I am talking about only point-to-point chat , not a global one.
Thx
Was This Post Helpful? 0
  • +
  • -

#6 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 291
  • View blog
  • Posts: 1,900
  • Joined: 25-October 06

Re: Programmin a chat

Posted 04 August 2009 - 06:05 AM

View Postelibengigi, on 4 Aug, 2009 - 11:54 AM, said:

View Posthorace, on 4 Aug, 2009 - 04:25 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 11:10 AM, said:

View Posthorace, on 4 Aug, 2009 - 03:05 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 09:56 AM, said:

We do a project which is plug-in of built-in-chat on websites. We are working with a database in order to store all the details of the chat users . We did all technical stuff of creating the DB and reading from it etc. but we encounter a big problem when we try to send a message from user A to user B . Actually we know how to send the msg from user A but we do not know how can user B gets it . How does he aware of getting a new msg ? and how does we find user B ? via IP , url or something ? because if so we don't know how to do it.
We will be happy to hear suggestions such as Technologies which solve the problem or another way to solve it.
Thank a lot in advance.
Eli

how do users join the chat? e.g. send you a UDP datagram ? if so you make a note of datagram source IP in your database. then use it to send messages to the user.


Thank you very much Hoarce . But i would be glad if you will be able to be more specific . I mean - what is the exact way you suggest to apply your idea : using threads ? sockets ? Does the JMS technolgy can be helpful?
Thank you again

it depends on how the chat operates - you can use TCP or UDP
(1) have a main thread with a TCP ServerSocket waiting for chat clients to connect
(2) when a client connects via TCP create a new thread to process the chat

it the intention for all clients to chat to all others, e.g. a message received is sent to all other clients (fairly simple), or would a client select someone to chat too (fairly complex)


So , you say that using threads and sockets is the best method? What's about its overhead? for instance if there are many users it is not so efficient to create a thread for each. am i right?

I am talking about only point-to-point chat , not a global one.
Thx

unless you are doing a simple one to one chat program you need a central server to act as the excange. TCP sockets are probably the simplest way to do this with a seperate thread to process the IO of each client - remember the threads share code and global data so it is not as inefficent as it sounds (each thread has its own local data). With the exchange how will a new client know who is available to chat, e.g. will you send them a list of available clients?
Also will the clients chat via the server or directly to each other (where you can have problems with firewalls and NAT boxes)

This post has been edited by horace: 04 August 2009 - 06:07 AM

Was This Post Helpful? 0
  • +
  • -

#7 elibengigi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 04-August 09

Re: Programmin a chat

Posted 04 August 2009 - 07:41 AM

View Posthorace, on 4 Aug, 2009 - 05:05 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 11:54 AM, said:

View Posthorace, on 4 Aug, 2009 - 04:25 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 11:10 AM, said:

View Posthorace, on 4 Aug, 2009 - 03:05 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 09:56 AM, said:

We do a project which is plug-in of built-in-chat on websites. We are working with a database in order to store all the details of the chat users . We did all technical stuff of creating the DB and reading from it etc. but we encounter a big problem when we try to send a message from user A to user B . Actually we know how to send the msg from user A but we do not know how can user B gets it . How does he aware of getting a new msg ? and how does we find user B ? via IP , url or something ? because if so we don't know how to do it.
We will be happy to hear suggestions such as Technologies which solve the problem or another way to solve it.
Thank a lot in advance.
Eli

how do users join the chat? e.g. send you a UDP datagram ? if so you make a note of datagram source IP in your database. then use it to send messages to the user.


Thank you very much Hoarce . But i would be glad if you will be able to be more specific . I mean - what is the exact way you suggest to apply your idea : using threads ? sockets ? Does the JMS technolgy can be helpful?
Thank you again

it depends on how the chat operates - you can use TCP or UDP
(1) have a main thread with a TCP ServerSocket waiting for chat clients to connect
(2) when a client connects via TCP create a new thread to process the chat

it the intention for all clients to chat to all others, e.g. a message received is sent to all other clients (fairly simple), or would a client select someone to chat too (fairly complex)


So , you say that using threads and sockets is the best method? What's about its overhead? for instance if there are many users it is not so efficient to create a thread for each. am i right?

I am talking about only point-to-point chat , not a global one.
Thx

unless you are doing a simple one to one chat program you need a central server to act as the excange. TCP sockets are probably the simplest way to do this with a seperate thread to process the IO of each client - remember the threads share code and global data so it is not as inefficent as it sounds (each thread has its own local data). With the exchange how will a new client know who is available to chat, e.g. will you send them a list of available clients?
Also will the clients chat via the server or directly to each other (where you can have problems with firewalls and NAT boxes)


My goal to do only one-to-one chat but with many users of course. And yes , i do intend to post to every chatter a list of online users which he can talk with (by the help of the data base) - but my main point stayed unclear - once a chatter knows about the existence of another chatter how does he "find" the thread which the received-chatter is listened to?
and also if i understood you correctly - every chatter has one thread which is used as both server (listen to incoming msg) and client (try to connect to other people) correct me if i am wrong (both questions) , thx.
Was This Post Helpful? 0
  • +
  • -

#8 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 291
  • View blog
  • Posts: 1,900
  • Joined: 25-October 06

Re: Programmin a chat

Posted 04 August 2009 - 08:38 AM

View Postelibengigi, on 4 Aug, 2009 - 01:41 PM, said:

View Posthorace, on 4 Aug, 2009 - 05:05 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 11:54 AM, said:

View Posthorace, on 4 Aug, 2009 - 04:25 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 11:10 AM, said:

View Posthorace, on 4 Aug, 2009 - 03:05 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 09:56 AM, said:

We do a project which is plug-in of built-in-chat on websites. We are working with a database in order to store all the details of the chat users . We did all technical stuff of creating the DB and reading from it etc. but we encounter a big problem when we try to send a message from user A to user B . Actually we know how to send the msg from user A but we do not know how can user B gets it . How does he aware of getting a new msg ? and how does we find user B ? via IP , url or something ? because if so we don't know how to do it.
We will be happy to hear suggestions such as Technologies which solve the problem or another way to solve it.
Thank a lot in advance.
Eli

how do users join the chat? e.g. send you a UDP datagram ? if so you make a note of datagram source IP in your database. then use it to send messages to the user.


Thank you very much Hoarce . But i would be glad if you will be able to be more specific . I mean - what is the exact way you suggest to apply your idea : using threads ? sockets ? Does the JMS technolgy can be helpful?
Thank you again

it depends on how the chat operates - you can use TCP or UDP
(1) have a main thread with a TCP ServerSocket waiting for chat clients to connect
(2) when a client connects via TCP create a new thread to process the chat

it the intention for all clients to chat to all others, e.g. a message received is sent to all other clients (fairly simple), or would a client select someone to chat too (fairly complex)


So , you say that using threads and sockets is the best method? What's about its overhead? for instance if there are many users it is not so efficient to create a thread for each. am i right?

I am talking about only point-to-point chat , not a global one.
Thx

unless you are doing a simple one to one chat program you need a central server to act as the excange. TCP sockets are probably the simplest way to do this with a seperate thread to process the IO of each client - remember the threads share code and global data so it is not as inefficent as it sounds (each thread has its own local data). With the exchange how will a new client know who is available to chat, e.g. will you send them a list of available clients?
Also will the clients chat via the server or directly to each other (where you can have problems with firewalls and NAT boxes)


My goal to do only one-to-one chat but with many users of course. And yes , i do intend to post to every chatter a list of online users which he can talk with (by the help of the data base) - but my main point stayed unclear - once a chatter knows about the existence of another chatter how does he "find" the thread which the received-chatter is listened to?
and also if i understood you correctly - every chatter has one thread which is used as both server (listen to incoming msg) and client (try to connect to other people) correct me if i am wrong (both questions) , thx.

I have done this two ways
(1) when a chat client connects they get a list of available clients to chat too. They select one and get the clients IP - they can then chat by sending and receiveing UDP datagrams (or alternativly each client can run a TCP server to receive and send chats). This is faily simple (the chat server only dealing with the lists of client) but can have problems if the client is behind firewalls or NAT boxes.
(2) the chat server acts as an exchange. When a client selects another to chat too messages are sent to the chat server which passess them to the selected client. As you say the client thread deals with transmission and receiving - it is faily compilex I seem to remember using Java callbacks at some point (see http://www.javaworld...javatip10.html).

an alternative to using sockets is RMI.

This post has been edited by horace: 04 August 2009 - 08:38 AM

Was This Post Helpful? 0
  • +
  • -

#9 elibengigi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 04-August 09

Re: Programmin a chat

Posted 04 August 2009 - 10:41 AM

View Posthorace, on 4 Aug, 2009 - 07:38 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 01:41 PM, said:

View Posthorace, on 4 Aug, 2009 - 05:05 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 11:54 AM, said:

View Posthorace, on 4 Aug, 2009 - 04:25 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 11:10 AM, said:

View Posthorace, on 4 Aug, 2009 - 03:05 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 09:56 AM, said:

We do a project which is plug-in of built-in-chat on websites. We are working with a database in order to store all the details of the chat users . We did all technical stuff of creating the DB and reading from it etc. but we encounter a big problem when we try to send a message from user A to user B . Actually we know how to send the msg from user A but we do not know how can user B gets it . How does he aware of getting a new msg ? and how does we find user B ? via IP , url or something ? because if so we don't know how to do it.
We will be happy to hear suggestions such as Technologies which solve the problem or another way to solve it.
Thank a lot in advance.
Eli

how do users join the chat? e.g. send you a UDP datagram ? if so you make a note of datagram source IP in your database. then use it to send messages to the user.


Thank you very much Hoarce . But i would be glad if you will be able to be more specific . I mean - what is the exact way you suggest to apply your idea : using threads ? sockets ? Does the JMS technolgy can be helpful?
Thank you again

it depends on how the chat operates - you can use TCP or UDP
(1) have a main thread with a TCP ServerSocket waiting for chat clients to connect
(2) when a client connects via TCP create a new thread to process the chat

it the intention for all clients to chat to all others, e.g. a message received is sent to all other clients (fairly simple), or would a client select someone to chat too (fairly complex)


So , you say that using threads and sockets is the best method? What's about its overhead? for instance if there are many users it is not so efficient to create a thread for each. am i right?

I am talking about only point-to-point chat , not a global one.
Thx

unless you are doing a simple one to one chat program you need a central server to act as the excange. TCP sockets are probably the simplest way to do this with a seperate thread to process the IO of each client - remember the threads share code and global data so it is not as inefficent as it sounds (each thread has its own local data). With the exchange how will a new client know who is available to chat, e.g. will you send them a list of available clients?
Also will the clients chat via the server or directly to each other (where you can have problems with firewalls and NAT boxes)


My goal to do only one-to-one chat but with many users of course. And yes , i do intend to post to every chatter a list of online users which he can talk with (by the help of the data base) - but my main point stayed unclear - once a chatter knows about the existence of another chatter how does he "find" the thread which the received-chatter is listened to?
and also if i understood you correctly - every chatter has one thread which is used as both server (listen to incoming msg) and client (try to connect to other people) correct me if i am wrong (both questions) , thx.

I have done this two ways
(1) when a chat client connects they get a list of available clients to chat too. They select one and get the clients IP - they can then chat by sending and receiveing UDP datagrams (or alternativly each client can run a TCP server to receive and send chats). This is faily simple (the chat server only dealing with the lists of client) but can have problems if the client is behind firewalls or NAT boxes.
(2) the chat server acts as an exchange. When a client selects another to chat too messages are sent to the chat server which passess them to the selected client. As you say the client thread deals with transmission and receiving - it is faily compilex I seem to remember using Java callbacks at some point (see http://www.javaworld...javatip10.html).

an alternative to using sockets is RMI.


Thank you very very much Horace . You helped me a lot.
Was This Post Helpful? 0
  • +
  • -

#10 elibengigi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 04-August 09

Re: Programmin a chat

Posted 04 August 2009 - 02:12 PM

View Postelibengigi, on 4 Aug, 2009 - 09:41 AM, said:

View Posthorace, on 4 Aug, 2009 - 07:38 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 01:41 PM, said:

View Posthorace, on 4 Aug, 2009 - 05:05 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 11:54 AM, said:

View Posthorace, on 4 Aug, 2009 - 04:25 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 11:10 AM, said:

View Posthorace, on 4 Aug, 2009 - 03:05 AM, said:

View Postelibengigi, on 4 Aug, 2009 - 09:56 AM, said:

We do a project which is plug-in of built-in-chat on websites. We are working with a database in order to store all the details of the chat users . We did all technical stuff of creating the DB and reading from it etc. but we encounter a big problem when we try to send a message from user A to user B . Actually we know how to send the msg from user A but we do not know how can user B gets it . How does he aware of getting a new msg ? and how does we find user B ? via IP , url or something ? because if so we don't know how to do it.
We will be happy to hear suggestions such as Technologies which solve the problem or another way to solve it.
Thank a lot in advance.
Eli

how do users join the chat? e.g. send you a UDP datagram ? if so you make a note of datagram source IP in your database. then use it to send messages to the user.


Thank you very much Hoarce . But i would be glad if you will be able to be more specific . I mean - what is the exact way you suggest to apply your idea : using threads ? sockets ? Does the JMS technolgy can be helpful?
Thank you again

it depends on how the chat operates - you can use TCP or UDP
(1) have a main thread with a TCP ServerSocket waiting for chat clients to connect
(2) when a client connects via TCP create a new thread to process the chat

it the intention for all clients to chat to all others, e.g. a message received is sent to all other clients (fairly simple), or would a client select someone to chat too (fairly complex)


So , you say that using threads and sockets is the best method? What's about its overhead? for instance if there are many users it is not so efficient to create a thread for each. am i right?

I am talking about only point-to-point chat , not a global one.
Thx

unless you are doing a simple one to one chat program you need a central server to act as the excange. TCP sockets are probably the simplest way to do this with a seperate thread to process the IO of each client - remember the threads share code and global data so it is not as inefficent as it sounds (each thread has its own local data). With the exchange how will a new client know who is available to chat, e.g. will you send them a list of available clients?
Also will the clients chat via the server or directly to each other (where you can have problems with firewalls and NAT boxes)


My goal to do only one-to-one chat but with many users of course. And yes , i do intend to post to every chatter a list of online users which he can talk with (by the help of the data base) - but my main point stayed unclear - once a chatter knows about the existence of another chatter how does he "find" the thread which the received-chatter is listened to?
and also if i understood you correctly - every chatter has one thread which is used as both server (listen to incoming msg) and client (try to connect to other people) correct me if i am wrong (both questions) , thx.

I have done this two ways
(1) when a chat client connects they get a list of available clients to chat too. They select one and get the clients IP - they can then chat by sending and receiveing UDP datagrams (or alternativly each client can run a TCP server to receive and send chats). This is faily simple (the chat server only dealing with the lists of client) but can have problems if the client is behind firewalls or NAT boxes.
(2) the chat server acts as an exchange. When a client selects another to chat too messages are sent to the chat server which passess them to the selected client. As you say the client thread deals with transmission and receiving - it is faily compilex I seem to remember using Java callbacks at some point (see http://www.javaworld...javatip10.html).

an alternative to using sockets is RMI.


Thank you very very much Horace . You helped me a lot.


Sorry for asking again but my program is actually a kind of extension to the browser , using sockets is impossible as far as i understood since all this process happens on the browser (which already listens to a specific port) so i thought about something like - there will be room chats in browser tabs , but my problem is , when a user wants to send a msg to room 124 ,for instance , what information should he know about the users there in order to get them seeing the new msg in their open room.
Is this sounds logic to open a new tab for every chat conversation for each group? Hope i was clear. Thx again
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1