private void HandleNotification(PyPacket packet) { if (packet.Destination is PyAddressBroadcast == false) { Log.Error("Received a notification that is not a broadcast..."); return; } PyAddressBroadcast destination = packet.Destination as PyAddressBroadcast; if (packet.UserID != -1) { Log.Trace($"Relaying notification to client {packet.UserID}"); this.ConnectionManager.NotifyClient((int)packet.UserID, packet); return; } // special situation, the ClusterController has to take care of fullfiling the proper information // in the packet, like UserID switch (destination.IDType) { case "solarsystemid2": this.ConnectionManager.NotifyBySolarSystemID2(packet, destination); break; case "constellationid": this.ConnectionManager.NotifyByConstellationID(packet, destination); break; case "corpid": this.ConnectionManager.NotifyByCorporationID(packet, destination); break; case "regionid": this.ConnectionManager.NotifyByRegionID(packet, destination); break; case "charid": this.ConnectionManager.NotifyByCharacterID(packet, destination); break; case "stationid": this.ConnectionManager.NotifyByStationID(packet, destination); break; case "allianceid": this.ConnectionManager.NotifyByAllianceID(packet, destination); break; case "nodeid": this.ConnectionManager.NotifyByNodeID(packet, destination); break; // TODO: IMPLEMENT OTHER NOTIFICATION ID TYPES BASED ON THE CLIENT CODE IF THEY'RE ACTUALLY USEFUL default: Log.Error($"Unexpected broadcast with idtype {destination.IDType.Value} and negative userID (autofill by ClusterController)"); break; } }
public void NotifyByCharacterID(PyPacket packet, PyAddressBroadcast destination) { lock (this.Clients) { PyList idlist = destination.IDsOfInterest; foreach (PyDataType idData in idlist) { PyInteger id = idData as PyInteger; foreach (KeyValuePair <long, ClientConnection> entry in this.Clients) { if (entry.Value.CharacterID == id) { // use the key instead of AccountID as this should be faster packet.UserID = entry.Key; // change the ids of interest to hide the character's we've notified destination.IDsOfInterest = new PyDataType[] { id }; // queue the packet for the user entry.Value.Socket.Send(packet); } } } } }
public void NotifyByNodeID(PyPacket packet, PyAddressBroadcast destination) { lock (this.Nodes) { foreach (PyInteger id in destination.IDsOfInterest.GetEnumerable <PyInteger>()) { if (this.Nodes.TryGetValue(id, out NodeConnection connection) == false) { Log.Warning("Trying to notify a node that is not connected anymore..."); continue; } // use the key instead of AccountID as this should be faster packet.UserID = id; // queue the packet for the user connection.Socket.Send(packet); } } }
public void NotifyByAllianceID(PyPacket packet, PyAddressBroadcast destination) { lock (this.Clients) { foreach (PyInteger id in destination.IDsOfInterest.GetEnumerable <PyInteger>()) { foreach ((long userID, ClientConnection connection) in this.Clients) { if (connection.AllianceID == id) { // use the key instead of AccountID as this should be faster packet.UserID = userID; // queue the packet for the user connection.Socket.Send(packet); } } } } }
public void NotifyByRegionID(PyPacket packet, PyAddressBroadcast destination) { lock (this.Clients) { foreach (PyDataType idData in destination.IDsOfInterest) { PyInteger id = idData as PyInteger; foreach (KeyValuePair <long, ClientConnection> entry in this.Clients) { if (entry.Value.RegionID == id) { // use the key instead of AccountID as this should be faster packet.UserID = entry.Key; // queue the packet for the user entry.Value.Socket.Send(packet); } } } } }
public void NotifyByCorporationID(PyPacket packet, PyAddressBroadcast destination) { lock (this.Clients) { foreach (PyDataType idData in destination.IDsOfInterest) { PyInteger id = idData as PyInteger; foreach ((long userID, ClientConnection connection) in this.Clients) { if (connection.CorporationID == id) { // use the key instead of AccountID as this should be faster packet.UserID = userID; // queue the packet for the user connection.Socket.Send(packet); } } } } }
public void NotifyByCharacterID(PyPacket packet, PyAddressBroadcast destination) { lock (this.Clients) { foreach (PyInteger id in destination.IDsOfInterest.GetEnumerable <PyInteger>()) { foreach ((long userID, ClientConnection connection) in this.Clients) { if (connection.CharacterID == id) { // use the key instead of AccountID as this should be faster packet.UserID = userID; // change the ids of interest to hide the character's we've notified destination.IDsOfInterest = new PyList(1) { [0] = id }; // queue the packet for the user connection.Socket.Send(packet); } } } } }