Exemplo n.º 1
0
        public static SlpPacket ReadPacket(SlpBinaryReader data)
        {
            SlpPacket newPacket = null;

            SlpHeaderPacket header = new SlpHeaderPacket(SlpFunctionId.None);

            header.ReadData(data);

            switch (header.FunctionId)
            {
            case SlpFunctionId.ServiceRequest:
                newPacket = new ServiceRequestPacket();
                break;

            case SlpFunctionId.ServiceReply:
                newPacket = new ServiceReplyPacket();
                break;

            case SlpFunctionId.ServiceRegistration:
                newPacket = new ServiceRegistrationPacket();
                break;

            case SlpFunctionId.ServiceDeRegister:
                newPacket = new ServiceDeregistrationPacket();
                break;

            case SlpFunctionId.ServiceAcknowledge:
                newPacket = new ServiceAcknowledgePacket();
                break;

            case SlpFunctionId.DirectoryAgentAdvert:
                newPacket = new DirectoryAgentAdvertPacket();
                break;

            case SlpFunctionId.ServiceAgentAdvert:
                newPacket = new ServiceAgentAdvertPacket();
                break;

            case SlpFunctionId.AttributeRequest:
                newPacket = new AttributeRequestPacket();
                break;

            case SlpFunctionId.AttributeReply:
                newPacket = new AttributeReplyPacket();
                break;

            case SlpFunctionId.ServiceTypeRequest:
                newPacket = new ServiceTypeRequestPacket();
                break;

            case SlpFunctionId.ServiceTypeReply:
                newPacket = new ServiceTypeReplyPacket();
                break;
            }

            if (newPacket != null)
            {
                newPacket.Header = header;
                newPacket.ReadData(data);
            }

            return(newPacket);
        }
Exemplo n.º 2
0
 public static void WritePacket(SlpPacket packet, SlpBinaryWriter data)
 {
     packet.WriteHeader(data);
     packet.WriteData(data);
     packet.WriteLength(data);
 }