public override void Notice(GetNoticeEventArgs e) { Notice(owner, e); owner.Notice(e); }
/// <summary> /// 通知所有观察者 /// </summary> /// <param name="e">通知的事件</param> public virtual void Notice(GetNoticeEventArgs e) { Notice(this, e); }
/// <summary> /// 通知所有观察者,注意,该种重载不会通知总监控 /// </summary> /// <param name="sender">发送消息的类</param> /// <param name="e">通知的事件</param> public virtual void Notice(Object sender, GetNoticeEventArgs e) { if (getNoticeEvent == null) return; if (useNoticeAsync)//判断是否使用异步 { getNoticeEvent.BeginInvoke(sender, e, null, null); } else { getNoticeEvent(sender, e); } }
//以下为客户端消息 private static GetNoticeEventArgs GetClientSystem(THEClient owner) { GetNoticeEventArgs e = new GetNoticeEventArgs(owner, Attribute.ClientSystem); return e; }
private static GetNoticeEventArgs GetTHEServerSystem(THEServer owner) { GetNoticeEventArgs e = new GetNoticeEventArgs(owner, Attribute.THEServerSystem); return e; }
public static GetNoticeEventArgs GetSendToClients(THEServer sender, List<THEServer.User> commucateUsers, string msg) { GetNoticeEventArgs e = new GetNoticeEventArgs(sender, Attribute.SendToClient); e.relatedUsers = commucateUsers; e.commucateMessage = msg; int num = commucateUsers.Count; string clientInfo = ""; string showClientInfo = ""; foreach (THEServer.User u in commucateUsers) { EndPoint RemoteEndPoint = u.client.Client.RemoteEndPoint; showClientInfo += RemoteEndPoint + "\r\n"; clientInfo += RemoteEndPoint + ","; } e.content = string.Format("SendToClients,{0},{1}{2}", num, clientInfo, msg); e.message = string.Format("向{0}个客户端发送消息:\r\n{1}内容为:\r\n{2}", num, showClientInfo, msg); return e; }
public static GetNoticeEventArgs GetSendToTHEServer(THEClient sender, string msg) { GetNoticeEventArgs e = new GetNoticeEventArgs(sender, Attribute.SendToTHEServer); e.commucateMessage = msg; e.content = String.Format("Send,{0}", msg); e.message = String.Format("向服务器发送:\r\n{0}", msg); return e; }
public static GetNoticeEventArgs GetSendToAll(THEServer sender, string msg) { GetNoticeEventArgs e = new GetNoticeEventArgs(sender, Attribute.SendToAll); e.commucateMessage = msg; int num = sender.users.Count; e.content = string.Format("SendToAll,{0},{1}", num, msg); e.message = string.Format("向所有客户端(共{0}个)广播:\r\n{1}", num, msg); return e; }
public static GetNoticeEventArgs GetSendToClient(THEServer sender, THEServer.User commucateUser, string msg) { GetNoticeEventArgs e = new GetNoticeEventArgs(sender, Attribute.SendToClient); e.relatedUser = commucateUser; e.commucateMessage = msg; EndPoint RemoteEndPoint = commucateUser.client.Client.RemoteEndPoint; e.content = string.Format("SendToClient,{0},{1}", RemoteEndPoint, msg); e.message = string.Format("向客户端{0}发送消息:\r\n{1}", RemoteEndPoint, msg); return e; }
public static GetNoticeEventArgs GetReceiveFromTHEServer(THEClient sender, string msg) { GetNoticeEventArgs e = new GetNoticeEventArgs(sender, Attribute.ReceiveFromTHEServer); e.commucateMessage = msg; e.content = String.Format("ReceiveFromTHEServer,{0}", msg); e.message = String.Format("接收到服务器内容:\r\n{0}", msg); return e; }
public static GetNoticeEventArgs GetSendFailed(THEClient sender, string msg) { GetNoticeEventArgs e = new GetNoticeEventArgs(sender, Attribute.SendFailed); e.commucateMessage = msg; e.content = String.Format("SendFailed,{0}", msg); e.message = String.Format("向服务器发送失败!发送内容:\r\n{0}", msg); return e; }
public static GetNoticeEventArgs GetClientRemove(THEServer sender, THEServer.User beRemovedUser) { GetNoticeEventArgs e = new GetNoticeEventArgs(sender, Attribute.ClientRemove); e.relatedUser = beRemovedUser; EndPoint RemoteEndPoint = beRemovedUser.client.Client.RemoteEndPoint; e.content = string.Format("ClientRemove,{0}", RemoteEndPoint); e.message = string.Format("咦!Master竟然不让我理这位客户端sama!是她做什么坏事了嘛0 0?→{0}", RemoteEndPoint); return e; }
public static GetNoticeEventArgs GetClientLost(THEServer sender, THEServer.User beRemovedUser) { GetNoticeEventArgs e = new GetNoticeEventArgs(sender, Attribute.ClientLost); e.relatedUser = beRemovedUser; EndPoint RemoteEndPoint = beRemovedUser.client.Client.RemoteEndPoint; e.content = string.Format("ClientLost,{0}", RemoteEndPoint); e.message = string.Format("不好啦!不好啦!这位客户端失踪了( ⊙ o ⊙ )→{0}", RemoteEndPoint); return e; }
public static GetNoticeEventArgs GetClientLogoff(THEServer sender, THEServer.User logoffUser) { GetNoticeEventArgs e = new GetNoticeEventArgs(sender, Attribute.ClientLogoff); e.relatedUser = logoffUser; EndPoint RemoteEndPoint = logoffUser.client.Client.RemoteEndPoint; e.content = string.Format("ClientLogoff,{0}", RemoteEndPoint); e.message = string.Format("好桑心T^T有一个客户端姐姐不理我啦。这货→{0}", RemoteEndPoint); return e; }
//以下为服务端非系统类型 public static GetNoticeEventArgs GetClientLogin(THEServer sender, THEServer.User connectUser) { GetNoticeEventArgs e = new GetNoticeEventArgs(sender, Attribute.ClientLogin); e.relatedUser = connectUser; EndPoint RemoteEndPoint = connectUser.client.Client.RemoteEndPoint; e.content = string.Format("ClientLogin,{0}", RemoteEndPoint); e.message = string.Format("哼哼~~有一个客户端姐姐连接啦。客户端信息:{0}", RemoteEndPoint); return e; }
public void log(System.Object sender, GetNoticeEventArgs e) { Debug.Log(e.message); }