代码之家  ›  专栏  ›  技术社区  ›  user366312

如何在WCF中引发GUI事件?(二)

  •  0
  • user366312  · 技术社区  · 6 年前

    我的问题是“为什么我的修改不起作用?”而不是“如何在WCF中创建聊天应用程序?”

    Here is the entire source code after modification.

    我已经改了 this application

    即。 ChatClient

    public partial class ChatClient : Form, IChatService
    {
    }
    

    被分成几个文件,并且 已重命名为 ChatClientForm :

    public class ChatClientForm {}
    public class ChatService : IChatService{}
    public interface IChatChannel : IChatService, IClientChannel {}
    public interface IChatService{}
    

    现在,问题是:服务器启动,用户可以登录,但无法发送和接收消息。

    enter image description here

    0 回复  |  直到 6 年前
        1
  •  1
  •   mahlatse    6 年前

    考虑到您的问题是关于聊天应用程序(而不是一直轮询),您可以使用 Duplex Services in WCF , 这将允许您将数据发送到服务器,并允许服务器将数据发送回您的应用程序,网上应该有很多关于在聊天应用程序中使用此服务类型的示例,您可以在

    https://www.codeproject.com/Articles/25261/A-WCF-WPF-Chat-Application

    其思想是打开一个通道,当有其他客户机向其发送消息时,服务器可以回复该通道