/// <summary> /// register a new server /// </summary> /// <param name="sender"> Server sender : the server who want to be registerd</param> /// <returns>returns a ClientIdentifier</returns> public ClientIdentifier registerServer(Server sender) { if (sender.identifier.serverID == -1) { if (sender.Authentication == null) { return(null); } sender.identifier.serverID = newConnection(); var stats = new Stats(); if (sender.Authentication.rights == Authentication.Rights.PATIENT) { sender.Statistics = new Stats(); } servers.Add(sender); var ident = new ClientIdentifier(sender.identifier.serverID, sender.Authentication.getEncrypted()[0], sender.Authentication.rights); sender.identifier = ident; updateNotifyWanted(); loadHistory(sender); } return(null); }
/// <summary> /// a textmessage /// </summary> /// <param name="text">string text : the real message the Textmessage contains</param> /// <param name="target">ClientIndentifier target : the desetination of the TextMessage</param> /// <param name="source">ClientIndentifier source : the object that created the TextMessage</param> public TextMessage(string text, ClientIdentifier target, ClientIdentifier source) { this.text = text; this.target = target; this.source = source; messageTime = DateTime.Now; }
/// <summary> /// a server /// </summary> /// <param name="client">TCPClient client</param> /// <param name="dataServer">DataServer dataServer</param> public Server(TcpClient client, DataServer dataServer) : base(client, true) { server = dataServer; notifiers = new List <int>(); identifier = new ClientIdentifier(-1, "UNKNOWN", Authentication.Rights.UNKNOWN); }
/// <summary> /// unfollow the current client being followed /// </summary> public void unfollowIdentifieer() { if (follow == null) { return; } sendData(new Message(Commands.UNFOLLOW, follow)); follow = null; }
public int registerListener(ClientIdentifier identifier) { var amount = listeningTo.Count(arg => arg.serverID == identifier.serverID); if (amount == 0) { sendData(new Message(Commands.FOLLOW, identifier)); } listeningTo.Add(identifier); return(listeningTo.Count - 1); }
/// <summary> /// follow a client /// </summary> /// <param name="identifier">ClientIdentifier identifier : the client</param> public void followIdentifieer(ClientIdentifier identifier) { if (follow == identifier) { return; } if (follow != null) { unfollowIdentifieer(); } sendData(new Message(Commands.FOLLOW, identifier)); follow = identifier; }
public void removeListener(int index, ClientIdentifier identifier) { if ((index >= 0) && (index < listeningTo.Count)) { listeningTo.RemoveAt(index); } var amount = listeningTo.Count(arg => arg.serverID == identifier.serverID); if (amount == 0) { sendData(new Message(Commands.UNFOLLOW, identifier)); } }
public void exception(ClientIdentifier sender, string exception) { Console.WriteLine(exception); foreach (var server in servers) { if (server.Authentication.rights == Authentication.Rights.ADMIN) { if (sender == null) { server.sendData(new Message(Commands.ERROR, exception)); } else { server.sendData(new Message(Commands.ERROR, sender + ":" + exception)); } } } }
/// <summary> /// refres the messages of a client /// </summary> /// <param name="focus">ClientIndentifier focus : the client</param> public void refreshMessages(ClientIdentifier focus) { this.focus = focus; MessageNotifier.Invoke(filter()); }