Пример #1
0
        /// Last Modified: 10/24/10
        /// <summary>
        /// Attempts to unregister the child with the parent.
        /// </summary>
        /// -----------------------------------------------------
        /// PRECONDITIONS: The child must be registered with the parent.
        /// -----------------------------------------------------
        /// Parameters:
        /// -----------------------------------------------------
        /// POSTCONDITIONS: NA -- No postconditions exist.
        /// -----------------------------------------------------
        /// Exceptions:
        /// 1) NodeSocketInvalid
        /// 2) NodeUnknownException
        /// -----------------------------------------------------
        /// Return Value:
        private void UnregisterWithParent()
        {
            //Only attempt to unregister the child if the parent is valid.
            if (m_iepParentNode != null)
            {
                Register r = new Register(NodeSocket.GetLocalIP(), HostPort, "", GetNodeType());

                //Create a new packet to send to the parent.
                Packet p = new Packet(
                    Packet.EventTag.Unregister, //Protocol
                    NodeName,                   //SrcName -- Unique name to un-register the node with.
                    ParentNode.GetNodeType(),   //DestName -- Not used in registration.
                    r.ToString(),               //Msg
                    LogicalTime);               //Logical Time.

                //Send the packet synchronously.
                SendToParent(p);
            }   //END OF if (m_iepParentNode != null)...
        }
Пример #2
0
        /// Last Modified: 10/24/10
        /// <summary>
        /// Attempts to register the child node with the parent.
        /// </summary>
        /// -----------------------------------------------------
        /// PRECONDITIONS: Refer to the following arguments.
        /// -----------------------------------------------------
        /// Parameters:
        /// <param name="ipAddr">
        /// Contains the IPAddress of the parent.
        /// </param>
        /// <param name="nPort">
        /// Contains the port of the parent.
        /// </param>
        /// -----------------------------------------------------
        /// POSTCONDITIONS: NA -- No postconditions exist.
        /// -----------------------------------------------------
        /// Exceptions:
        /// 1) NodeSocketInvalid
        /// 2) NodeUnknownException
        /// -----------------------------------------------------
        /// Return Value:
        private void RegisterWithParent(IPAddress ipAddr, int nPort)
        {
            //Create the parent endpoint.
            m_iepParentNode = new IPEndPoint(ipAddr, nPort);

            Register r = new Register(NodeSocket.GetLocalIP(), HostPort, "", GetNodeType());

            //Create a new packet to send to the parent.
            Packet p = new Packet(
                Packet.EventTag.Register,  //Protocol
                NodeName,                  //SrcName -- Unique name to register the node with.
                ParentNode.GetNodeType(),  //DestName -- Not used in registration.
                r.ToString(),              //Msg
                LogicalTime);              //Logical Time.

            //Send the packet synchronously.
            SendToParent(p);
        }