客户端之间的MFC C ++聊天 [英] MFC C++ Chat between clients

查看:157
本文介绍了客户端之间的MFC C ++聊天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我制作了一个基于MFC C ++中的服务器/聊天的聊天程序.当我启动服务器和2-3个客户端时,从第一个客户端键入内容时,它将转到服务器和其他2个客户端.我想以某种方式在聊天中连接2个客户端,因此第3个客户端看不到聊天,但服务器可以看到.

类似于私人聊天.我正在寻找类似函数的内容,但我不知道该怎么做.感谢您提出的任何帮助!

Hello,

I made a chat program that is based on server/chat in MFC C++. When I start the server and 2-3 clients, and from the first client I type something, it goes to the server and the other 2 clients. I want to connect the 2 clients in chat in a way, so the 3rd client can''t see the chat but the server would be able to see it.

Something like a private chat. I''m looking for something like a function but I don''t know what exactly to do. Thanks for any help you suggest!

推荐答案

您可以通过以下两种方法进行操作:

0)您将不得不更改您的应用程序以发送对象,而不仅仅是发送文本.新对象可能包含目标用户名和要发送给他们的文本.然后,当服务器收到消息时,它仅将文本发送给指定的用户.如果未指定用户,则将文本发送给所有用户.

1)使客户端软件能够充当服务器,并产生一个新窗口,该窗口仅接受来自私人聊天用户的消息.这也意味着客户端/服务器将必须能够协商专用聊天会话的替代端口分配.

您还必须考虑同时进行多个私人会话的可能性.

继续并编写代码.

There are a couple of ways you can do this:

0) You''re going to have to change your app to send an object instead of just text. The new object would probably contain the targeted users name(s) and the text to be sent to them. Then when the server gets the message, it only sends the text to the users specified. If no users are specified, the text is sent to all users.

1) Have the client software be able to act a s a server, and spawn a new window that only accepts messages from the user that is privately chatting. This also means that the client/sever would have to be able to negotiate alternative port assignment for the private chat session.

You would also have to consider the possibility of multiple simultaneous private sessions.

Go forth, and code.


这篇关于客户端之间的MFC C ++聊天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆