在 C# 中选择要聊天的人
考虑一下有很多人在线的 LAN 信使的情况。 我需要选择一个特定的人来聊天。 我必须如何在 C# 中做到这一点? 我想要的是通过点击他的名字来选择一个特定的人。之后我输入的任何内容都必须发送,就像 IP Lanmessenger 软件的情况一样(希望你们已经使用过它)。 有人可以帮我吗?谢谢
Consider the case of a lan messenger where a number of people are online.
I need to select a particular person to chat with.
How must I go about doing so in C#?
What I want is to select a particular person by clicking on his name.After that I whatever I type must be sent just as in the case of the IP Lanmessenger software(hoping u people have used it).
Could someone help me out.Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想跟踪用户,我建议编写一个服务器应用程序来处理所有连接。 这是一个简单的示例(请注意,这不是一个完整的示例):
现在再次注意,这不是一个完整的示例,我知道我已经全力以赴,但我希望这能给您一个想法。 HandleMessage 函数中的消息部分可以是用户的 IP 地址(如果他们正在连接到聊天服务器/正在断开连接)以及您要指定的其他参数。 这是取自我为父亲公司编写的应用程序的代码,以便员工可以直接从我编写的自定义 CRM 中相互发送消息。 如果还有什么问题请评论。
If you want to keep track of users I advice coding a server application to handle all the connections. Here is a quick example (note this is not a complete example):
Now again note this isn't a complete example and I know I sort of went all out on this but I hope this gives you an idea. The message part in the HandleMessage function can be the users IP address, if they are connecting to the Chat server/Disconnecting, and other parameters that you want to specify. This is code taken from an application I wrote for my fathers company so that the employees could message each other right from the custom CRM I wrote. If you have any more questions please comment.
如果您正在构建聊天 UI,并且想要查看所有在线人员,则典型的 UI 元素将是一个列表框,然后是在框中某个项目的 On_Click 时触发的代码。 该代码可以打开另一个 UI 元素来开始聊天。
获取登录用户列表比较困难。 您将需要实现某种观察者/订阅者模式来处理来自您正在实现的聊天协议的通知。
GeekPedia 有一个关于 创建C# 中的聊天客户端和服务器。
If you are building the UI for a chat and you want to see all the people online the typical UI element would be a list box and then code that fires on the On_Click of an item in the box. That code could open another UI element to begin the chat.
Getting the list of users logged in is harder. You will need to implement some kind of Observer/Subscriber pattern to handle notifications from the chat protocol you are implementing.
GeekPedia has a great series on creating a chat client and server in C#.