Ejemplo n.º 1
0
        /// <summary>
        /// Creates a session change notification including only the last changes to the session
        /// </summary>
        /// <param name="container">Information about the current node the client is in</param>
        /// <returns>The packet ready to be sent</returns>
        private PyPacket CreateEmptySessionChange(NodeContainer container)
        {
            // Fill all the packet data, except the dest/source
            SessionChangeNotification scn = new SessionChangeNotification
            {
                Changes = Session.GenerateSessionChange()
            };

            if (scn.Changes.Length == 0)
            {
                // Nothing to do
                return(null);
            }

            // add ourselves as nodes of interest
            // TODO: DETECT NODE OF INTEREST BASED ON THE SERVER THAT HAS THE SOLAR SYSTEM LOADED IN
            scn.NodesOfInterest.Add(container.NodeID);

            PyPacket packet = new PyPacket(PyPacket.PacketType.SESSIONCHANGENOTIFICATION)
            {
                Source      = new PyAddressNode(container.NodeID),
                Destination = new PyAddressClient(this.Session["userid"] as PyInteger),
                UserID      = this.Session["userid"] as PyInteger,
                Payload     = scn,
                OutOfBounds = new PyDictionary()
                {
                    { "channel", "sessionchange" }
                }
            };

            return(packet);
        }
Ejemplo n.º 2
0
        public PyPacket CreateEmptySessionChange()
        {
            // Fill all the packet data, except the dest/source
            SessionChangeNotification scn = new SessionChangeNotification
            {
                Changes = Session.GenerateSessionChange()
            };

            if (scn.Changes.Length == 0)
            {
                // Nothing to do
                return(null);
            }

            PyPacket packet = new PyPacket(PyPacket.PacketType.SESSIONCHANGENOTIFICATION)
            {
                UserID      = this.Session["userid"] as PyInteger,
                Payload     = scn,
                OutOfBounds = new PyDictionary
                {
                    ["channel"] = "sessionchange"
                }
            };

            return(packet);
        }
Ejemplo n.º 3
0
        public PyPacket CreateEmptySessionChange()
        {
            // Fill all the packet data, except the dest/source
            SessionChangeNotification scn = new SessionChangeNotification();

            scn.changes = Session.EncodeChanges();

            if (scn.changes.Dictionary.Count == 0)
            {
                // Nothing to do
                return(null);
            }

            Dictionary <int, Connection> nodes = ConnectionManager.Nodes;

            // Add all the nodeIDs
            foreach (KeyValuePair <int, Connection> node in nodes)
            {
                scn.nodesOfInterest.Items.Add(new PyInt(node.Key));
            }

            PyPacket p = new PyPacket();

            p.type_string = "macho.SessionChangeNotification";
            p.type        = Macho.MachoNetMsg_Type.SESSIONCHANGENOTIFICATION;

            p.userID = (uint)AccountID;

            p.payload = scn.Encode().As <PyTuple>();

            p.named_payload = new PyDict();
            p.named_payload.Set("channel", new PyString("sessionchange"));

            return(p);
        }
Ejemplo n.º 4
0
        public PyPacket CreateEmptySessionChange()
        {
            // Fill all the packet data, except the dest/source
            SessionChangeNotification scn = new SessionChangeNotification();

            scn.changes = session.EncodeChanges();

            if (scn.changes.Dictionary.Count == 0)
            {
                // Nothing to do
                return(null);
            }

            // Add all the nodeIDs
            foreach (int node in NodeManager.nodes.Keys)
            {
                if (node == 0)
                {
                    continue;
                }

                scn.nodesOfInterest.Items.Add(new PyInt(node));
            }

            PyPacket p = new PyPacket();

            p.type_string = "macho.SessionChangeNotification";
            p.type        = Macho.MachoNetMsg_Type.SESSIONCHANGENOTIFICATION;

            p.userID = (uint)ClientManager.GetClientID(this);

            p.payload = scn.Encode().As <PyTuple>();

            p.named_payload = new PyDict();
            p.named_payload.Set("channel", new PyString("sessionchange"));

            return(p);
        }