Exemple #1
0
 // 当ProxyCallBackEvent事件触发,该方法将被调用
 // 它将通过检查ProxyCallBackEventArgs的参数值来判断收到的消息类型,
 // 然后调用相应的方法
 public void ProxySingleton_ProxyCallBackEvent(object sender,
 ProxyCallBackEventArgs e)
 {
     switch (e.callbackType)
     {
         case CallBackType.Receive:
             Receive(e.person.Name, e.message);
             break;
         case CallBackType.ReceiveWhisper:
             ReceiveWhisper(e.person.Name, e.message);
             break;
         case CallBackType.UserEnter:
             break;
         case CallBackType.UserLeave:
             break;
     }
 }
Exemple #2
0
 // 被UserEnter()以及UserLeave()调用,
 // 根据callbackType参数的值来封装消息,并触发ProxyCallBackEvent事件
 private void UserEnterLeave(Person person, CallBackType callbackType)
 {
     ProxyCallBackEventArgs e = new ProxyCallBackEventArgs();
     e.person = person;
     e.callbackType = callbackType;
     OnProxyCallBackEvent(e);
 }
Exemple #3
0
 // 根据callbacktype参数的值来封装消息,并触发ProxyCallBackEvent事件
 private void Receive(Person sender, string message, CallBackType callbackType)
 {
     ProxyCallBackEventArgs e = new ProxyCallBackEventArgs();
     e.message = message;
     e.callbackType = callbackType;
     e.person = sender;
     OnProxyCallBackEvent(e);
 }
Exemple #4
0
 // 触发ProxyCallBackEvent事件
 protected void OnProxyCallBackEvent(ProxyCallBackEventArgs e)
 {
     if (ProxyCallBackEvent != null)
     {
         ProxyCallBackEvent(this, e);
     }
 }