Пример #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 !!");
        }
Пример #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;
        }
Пример #3
0
        public static G2Packet getPacketByHeader(Header h)
        {
            G2Packet packet = null;
            switch(h.type) {
            case G2PacketType.PVU:
                packet = new G2PacketPVU (h);
                break;
            case G2PacketType.COM:
                packet = new G2PacketCOM (h);
                break;
            case G2PacketType.PART:
                packet = new G2PacketPART(h);
                break;
            case G2PacketType.SZ:
                packet = new G2PacketSZ (h);
                break;
            case G2PacketType.Q2:
                packet = new G2PacketQ2 (h);
                break;
            case G2PacketType.DN:
                packet = new G2PacketDN (h);
                break;
            case G2PacketType.KHL:
                packet = new G2PacketKHL (h);
                break;
            case G2PacketType.QA:
                packet = new G2PacketQA (h);
                break;
            case G2PacketType.SS:
                packet = new G2PacketSS (h);
                break;
            case G2PacketType.QH2:
                packet = new G2PacketQH2 (h);
                break;
            case G2PacketType.HG:
                packet = new G2PacketHG (h);
                break;
            case G2PacketType.PI:
                packet = new G2PacketPI (h);
                break;
            case G2PacketType.UDP:
                packet = new G2PacketUDP (h);
                break;
            case G2PacketType.PO:
                packet = new G2PacketPO (h);
                break;
            case G2PacketType.S:
                packet = new G2PacketS(h);
                break;
            case G2PacketType.D:
                packet = new G2PacketD(h);
                break;
            case G2PacketType.LNI:
                packet = new G2PacketLNI (h);
                break;
            case G2PacketType.GU:
                packet = new G2PacketGU (h);
                break;
            case G2PacketType.NA:
                packet = new G2PacketNA (h);
                break;
            case G2PacketType.QKR:
                packet = new G2PacketQKR (h);
                break;
            case G2PacketType.QKA:
                packet = new G2PacketQKA (h);
                break;
            case G2PacketType.SNA:
                packet = new G2PacketSNA (h);
                break;
            case G2PacketType.QNA:
                packet = new G2PacketQNA (h);
                break;
            case G2PacketType.V:
                packet = new G2PacketV (h);
                break;
            case G2PacketType.LS:
                packet = new G2PacketLS (h);
                break;
            case G2PacketType.HS:
                packet = new G2PacketHS (h);
                break;
            case G2PacketType.TLS:
                packet = new G2PacketTLS (h);
                break;
            case G2PacketType.TS:
                packet = new G2PacketTS (h);
                break;
            case G2PacketType.NH:
                packet = new G2PacketNH (h);
                break;
            case G2PacketType.RA:
                packet = new G2PacketRA (h);
                break;
            case G2PacketType.BUP:
                packet = new G2PacketBUP (h);
                break;
            case G2PacketType.H:
                packet = new G2PacketH (h);
                break;
            case G2PacketType.URL:
                packet = new G2PacketURL (h);
                break;
            case G2PacketType.URN:
                packet = new G2PacketURN (h);
                break;
            case G2PacketType.UPRO:
                packet = new G2PacketUPRO (h);
                break;
            case G2PacketType.NICK:
                packet = new G2PacketNICK (h);
                break;
            case G2PacketType.BH:
                packet = new G2PacketBH (h);
                break;
            case G2PacketType.FW:
                packet = new G2PacketFW (h);
                break;
            case G2PacketType.MD:
                packet = new G2PacketMD (h);
                break;
            case G2PacketType.UPROC:
               packet = new G2PacketUPROC(h);
               break;
            case G2PacketType.UPROD :
               packet = new G2PacketUPROD(h);
               break;
               case G2PacketType.XML:
               packet = new G2PacketXML(h);
               break;
            default :
                packet = new G2PacketDefault (h);
                break;

            }
            return packet;
        }
Пример #4
0
        public static G2Packet getPacketByHeader(Header h)
        {
            G2Packet packet = null;

            switch (h.type)
            {
            case G2PacketType.PVU:
                packet = new G2PacketPVU(h);
                break;

            case G2PacketType.COM:
                packet = new G2PacketCOM(h);
                break;

            case G2PacketType.PART:
                packet = new G2PacketPART(h);
                break;

            case G2PacketType.SZ:
                packet = new G2PacketSZ(h);
                break;

            case G2PacketType.Q2:
                packet = new G2PacketQ2(h);
                break;

            case G2PacketType.DN:
                packet = new G2PacketDN(h);
                break;

            case G2PacketType.KHL:
                packet = new G2PacketKHL(h);
                break;

            case G2PacketType.QA:
                packet = new G2PacketQA(h);
                break;

            case G2PacketType.SS:
                packet = new G2PacketSS(h);
                break;

            case G2PacketType.QH2:
                packet = new G2PacketQH2(h);
                break;

            case G2PacketType.HG:
                packet = new G2PacketHG(h);
                break;

            case G2PacketType.PI:
                packet = new G2PacketPI(h);
                break;

            case G2PacketType.UDP:
                packet = new G2PacketUDP(h);
                break;

            case G2PacketType.PO:
                packet = new G2PacketPO(h);
                break;

            case G2PacketType.S:
                packet = new G2PacketS(h);
                break;

            case G2PacketType.D:
                packet = new G2PacketD(h);
                break;

            case G2PacketType.LNI:
                packet = new G2PacketLNI(h);
                break;

            case G2PacketType.GU:
                packet = new G2PacketGU(h);
                break;

            case G2PacketType.NA:
                packet = new G2PacketNA(h);
                break;

            case G2PacketType.QKR:
                packet = new G2PacketQKR(h);
                break;

            case G2PacketType.QKA:
                packet = new G2PacketQKA(h);
                break;

            case G2PacketType.SNA:
                packet = new G2PacketSNA(h);
                break;

            case G2PacketType.QNA:
                packet = new G2PacketQNA(h);
                break;

            case G2PacketType.V:
                packet = new G2PacketV(h);
                break;

            case G2PacketType.LS:
                packet = new G2PacketLS(h);
                break;

            case G2PacketType.HS:
                packet = new G2PacketHS(h);
                break;

            case G2PacketType.TLS:
                packet = new G2PacketTLS(h);
                break;

            case G2PacketType.TS:
                packet = new G2PacketTS(h);
                break;

            case G2PacketType.NH:
                packet = new G2PacketNH(h);
                break;

            case G2PacketType.RA:
                packet = new G2PacketRA(h);
                break;

            case G2PacketType.BUP:
                packet = new G2PacketBUP(h);
                break;

            case G2PacketType.H:
                packet = new G2PacketH(h);
                break;

            case G2PacketType.URL:
                packet = new G2PacketURL(h);
                break;

            case G2PacketType.URN:
                packet = new G2PacketURN(h);
                break;

            case G2PacketType.UPRO:
                packet = new G2PacketUPRO(h);
                break;

            case G2PacketType.NICK:
                packet = new G2PacketNICK(h);
                break;

            case G2PacketType.BH:
                packet = new G2PacketBH(h);
                break;

            case G2PacketType.FW:
                packet = new G2PacketFW(h);
                break;

            case G2PacketType.MD:
                packet = new G2PacketMD(h);
                break;

            case G2PacketType.UPROC:
                packet = new G2PacketUPROC(h);
                break;

            case G2PacketType.UPROD:
                packet = new G2PacketUPROD(h);
                break;

            case G2PacketType.XML:
                packet = new G2PacketXML(h);
                break;

            default:
                packet = new G2PacketDefault(h);
                break;
            }
            return(packet);
        }
Пример #5
0
        private G2Packet HandlePacketLNI(NodePeer peer,G2PacketLNI pack)
        {
            G2Packet p = pack.getFirstChildPacket(G2PacketType.NA);
            if (p != null)
                peer.ListeningNode = ((G2PacketNA)p).node;

            p = pack.getFirstChildPacket(G2PacketType.GU);
            if (p != null)
                peer.Guid = ((G2PacketGU)p).nodeGuid;

            // can handle vendor code etc etc
            return null;
        }