public string getCommNodeMessage(int userId, int commNodeId, int from, int to) { string xml = ""; if (!Core.Core.Instance.users.ContainsKey(userId)) { return(xml); } if (!Core.Core.Instance.commNodes.ContainsKey(commNodeId)) { return(xml); } Core.User user = Core.Core.Instance.users[userId]; Core.CommunicationNode node = Core.Core.Instance.commNodes[commNodeId]; try { xml = (new BC.CommNode(node, user)).getCommNodeMessages(from, to); } catch (Exception ex) { SpacegameServer.Core.Core.Instance.writeExceptionToLog(ex); } return(xml); }
/// <summary> /// Wrong name. Does in fact check if the user may be added, then ALSO adds the user to the node /// </summary> /// <param name="user"></param> /// <param name="ship"></param> /// <param name="node"></param> /// <returns></returns> public static string checkShipAtCommNode(Core.User user, Core.Ship ship, Core.CommunicationNode node) { string ret = ""; //List<SpacegameServer.Core.DiplomaticRelation> newContacts = new List<SpacegameServer.Core.DiplomaticRelation>(); if (!node.checkAndAddUser(user, ship)) { return(ret); } SpacegameServer.BC.XMLGroups.CommNodeData nodeData = new SpacegameServer.BC.XMLGroups.CommNodeData(); //nodeData.xmlKnownUsers = SpacegameServer.BC.XMLGroups.UserContacts.createContacts(user, newContacts); nodeData.commNodes = new XMLGroups.CommNodes(); nodeData.commNodes.commNode = new List <XMLGroups.CommNode>(); nodeData.commNodes.commNode.Add(XMLGroups.CommNode.createCommNode(node, user)); //Todo: only transfer "new" alliance contact data //nodeData.allianceDiplomacy = XMLGroups.KnownAlliances.createAllianceContacts(user); //nodeData.allianceRelations = XMLGroups.AllianceUserRelations.createAllianceUserRelations(user); BusinessConnector.Serialize <SpacegameServer.BC.XMLGroups.CommNodeData>(nodeData, ref ret, true); return(ret); }
public static List <CommNode> createSingleNodeList(Core.CommunicationNode node, Core.User user) { List <CommNode> commNodes = new List <CommNode>(); //create known nodes if (Core.Core.Instance.commNodes.ContainsKey(node.id)) { CommNode xmlNode = CommNode.createCommNode( node, user); commNodes.Add(xmlNode); } return(commNodes); }
public string sendCommNodeMessage(int userId, int commNodeId, string header, string body) { /* * <messages> * <message> * <id>6</id> * <commNodeId>936</commNodeId> * <sender>157</sender> * <headline>Title</headline> * <messageBody>Today, the Prokyon Syndicate was founded.<br />We are a small group of traders living near the Algol 550 space station, which is at the coordinates 5000|5000.<br />Our products will soon be available at that station. I can especially recommend our high quality Yttrium metal. <br />In addition, we are offering trade treaties to all peaceful dwellers of this galaxy. <br /><br /><br />Yours sincerely,<br /><br />Skratti,<br />CEO Prokyon Syndicate</messageBody> * <sendingDate>2015-06-23T05:43:02</sendingDate> * <newMessage>0</newMessage> * </message> * <message> * <id>9</id> * <commNodeId>936</commNodeId> * <sender>186</sender> * <headline>Title</headline> * <messageBody>Dear neighbours!<br />Yesterday a plebiscite of the inhabitants of sector 4980/4980 to 5000/5000 ended with clear decision to close the borders of the sektor for security reasons.<br />Also, a security zone of one field around the sector will be established.<br /><br />Any ship entering the zone without previous declaration of intention, flight plan, destination and onboard cargo will be regarded as a thread and thus treated.<br /><br />Expect the diplomatic status to be changed to hostile in near future so al potentialy inevitable actions can be taken, if necessary.<br />This dont mean you have to fear any thread as long you stand clear of the borders and security zone.</messageBody> * <sendingDate>2015-06-26T19:19:56</sendingDate> * <newMessage>0</newMessage> * </message> * </messages> * */ string xml = ""; if (!Core.Core.Instance.users.ContainsKey(userId)) { return(xml); } if (!Core.Core.Instance.commNodes.ContainsKey(commNodeId)) { return(xml); } Core.User user = Core.Core.Instance.users[userId]; Core.CommunicationNode node = Core.Core.Instance.commNodes[commNodeId]; try { xml = (new BC.CommNode(node, user)).sendCommNodeMessages(header, body); } catch (Exception ex) { SpacegameServer.Core.Core.Instance.writeExceptionToLog(ex); } return(xml); }
public static CommNode createAllianceCommNode(SpacegameServer.Core.User user) { CommNode xmlNode = new CommNode(); Core.CommunicationNode node = Core.CommunicationNode.GetAllianceNode(user); xmlNode.node = node; if (node.commNodeUsers.ContainsKey(user.id)) { xmlNode.commNodeUser = node.commNodeUsers[user.id]; } xmlNode.visited = true; xmlNode.messageUnReadCount = xmlNode.visited ? node.commNodeMessages.Count(e => e.Key > node.commNodeUsers[user.id].lastReadMessage) : 0; return(xmlNode); }
public string checkShipAtCommNode(int userId, int shipId, int comNodeId) { string xml = ""; if (!Core.Core.Instance.users.ContainsKey(userId)) { return(xml); } if (!Core.Core.Instance.ships.ContainsKey(shipId)) { return(xml); } if (!Core.Core.Instance.commNodes.ContainsKey(comNodeId)) { return(xml); } Core.User user = Core.Core.Instance.users[userId]; Core.Ship ship = Core.Core.Instance.ships[shipId]; Core.CommunicationNode node = Core.Core.Instance.commNodes[comNodeId]; if (ship.userid != userId) { return(xml); } try { xml = BC.Ship.checkShipAtCommNode(user, ship, node); } catch (Exception ex) { SpacegameServer.Core.Core.Instance.writeExceptionToLog(ex); } return(xml); }
public CommNode(Core.CommunicationNode node, Core.User user) { this.node = node; this.user = user; core = SpacegameServer.Core.Core.Instance; }