K
K
Konstantin Malyarov2016-02-01 22:55:21
Java
Konstantin Malyarov, 2016-02-01 22:55:21

How to run a thread on the server, through the client?

There is a chat server. When a client connects, he sees contacts and a general chat. How to write a private message? There is an idea, for each personal chat (start a separate thread) to create your own arraylist, in which the dialogue output streams will be placed. Now the question is: How to start this thread? Send a string like name1_to_name2? The question arises, if you make such a request, can you write this line in any chat and the server will create another connection? If yes, how to avoid it. Or how to implement dialogues?
Implementation without a database.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Chudnovsky, 2016-02-02
@Frankenstine

It's all kind of confusing for you. When a client writes a message, it is sent to the server, and not in its pure form, but with a "header", which, for example, indicates that this is a personal message to such and such an addressee (as an option, the server independently parses the message for control commands of the form " /pm target_user target_message", then you can send a raw message without headers). Accordingly, the server sends such a message to only one (or how many there is implied) client, with the corresponding "private message" header.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question