WCF 该通道无法发送更多消息,因为已调用 IsTerminating 操作“Say”
服务端:
namespace ChatService
{
// SessionMode.Required 允许Session会话。双工协定时的回调协定类型为IChatCallback接口
[ServiceContract(SessionMode = SessionMode.Required, CallbackContract = typeof(IChatCallback))]
public interface IChat
{
//----->IsOneWay = false等待服务器完成对方法处理;IsInitiating = true启动Session会话,IsTerminating = false 设置服务器发送回复后不关闭会话
[OperationContract(IsOneWay = false, IsInitiating = true, IsTerminating = false)]
Person[] Join(Person name); //用户进入
[OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = true)]
void Leave(); //用户离开
//..............................................
[OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = true)]
void Say(string msg); // 群聊消息
[OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = true)]
void Whisper(Person name, string msg); //私聊消息
}
}
客服端:
//获取客户端通用操作类
private Proxy_Singleton ProxySingleton = Proxy_Singleton.GetInstance();
/// <summary>
/// 发送消息
/// </summary>
private void button1_Click(object sender, EventArgs e)
{
ProxySingleton.proxy.Say(textBox2.Text.Trim());
textBox2.Clear();
}
问题:第一条消息能发送出去,发送第二条消息时就出现异常“该通道无法发送更多消息,因为已调用 IsTerminating 操作“Say”。”
------解决方案--------------------先调一次join
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/
------解决方案--------------------[Op