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);
        }
示例#2
0
        /// <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);
        }
示例#3
0
        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.&lt;br /&gt;We are a small group of traders living near the Algol 550 space station, which is at the coordinates 5000|5000.&lt;br /&gt;Our products will soon be available at that station. I can especially recommend our high quality Yttrium metal. &lt;br /&gt;In addition, we are offering trade treaties to all peaceful dwellers of this galaxy. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Yours sincerely,&lt;br /&gt;&lt;br /&gt;Skratti,&lt;br /&gt;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!&lt;br /&gt;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.&lt;br /&gt;Also, a security zone of one field around the sector will be established.&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;Expect the diplomatic status to be changed to hostile in near future so al potentialy inevitable actions can be taken, if necessary.&lt;br /&gt;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);
        }
示例#5
0
        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);
        }
示例#7
0
 public CommNode(Core.CommunicationNode node, Core.User user)
 {
     this.node = node;
     this.user = user;
     core      = SpacegameServer.Core.Core.Instance;
 }