Beispiel #1
0
        public void testLNI(G2Packet packTest)
        {
            G2PacketLNI rLNI = (G2PacketLNI)packTest;
            G2PacketGU rGU = (G2PacketGU) rLNI.getFirstChildPacket (G2PacketType.GU);
            G2PacketNA rNA = (G2PacketNA) rLNI.getFirstChildPacket (G2PacketType.NA);
            G2PacketV rV = (G2PacketV)rLNI.getFirstChildPacket (G2PacketType.V);

            G2Packet lni = new G2PacketLNI();
            lni.AddChild (new G2PacketNA (rNA.node));
            lni.AddChild (new G2PacketGU (rGU.nodeGuid));
            lni.AddChild (new G2PacketV (rV.Str));
            lni.FinalizePacket ();
            G2Log.Write(lni.ToString());
            MemoryStream s1 = new MemoryStream ((int)rLNI.getTotalPacketLength ());
            MemoryStream s2 = new MemoryStream ((int)lni.getTotalPacketLength ());
            rLNI.Write (s1);
            lni.Write (s2);

            byte[] b1 = s1.ToArray ();
            byte[] b2 = s2.ToArray ();

            if (b1.Length != b2.Length) {
                G2Log.Write (" NOT EQUAL");
                return;
            }
            for (int i = 0; i < b1.Length; i++) {
                if (b1 [i] != b2 [i]) {
                    G2Log.Write ("NOT EQUAL");
                    return;
                }
            }
            G2Log.Write ("EQUAL !!");
        }
Beispiel #2
0
        public static G2PacketLNI SmartLNIPacket()
        {
            G2PacketLNI root = new G2PacketLNI();
            G2PacketGU guid = new G2PacketGU(GUID.generateGuid());
            root.AddChild(guid);

            NodeAddress self = new NodeAddress(G2Network.Instance.SelfAddress, G2Network.Instance.SelfPort);
            G2PacketNA na = new G2PacketNA(self);
            root.AddChild(na);

            G2PacketV v = new G2PacketV ("RAZA");
            root.AddChild (v);

            root.FinalizePacket();
            return root;
        }