Search in sources :

Example 21 with Packet

use of com.yahoo.fs4.Packet in project Citizens2 by CitizensDev.

the class EntityHumanNPC method updatePackets.

private void updatePackets(boolean navigating) {
    if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt())
        return;
    updateCounter = 0;
    Location current = getBukkitEntity().getLocation(packetLocationCache);
    Packet<?>[] packets = new Packet[navigating ? EnumItemSlot.values().length : EnumItemSlot.values().length + 1];
    if (!navigating) {
        packets[5] = new PacketPlayOutEntityHeadRotation(this, (byte) MathHelper.d(NMSImpl.getHeadYaw(this) * 256.0F / 360.0F));
    }
    int i = 0;
    for (EnumItemSlot slot : EnumItemSlot.values()) {
        packets[i++] = new PacketPlayOutEntityEquipment(getId(), slot, getEquipment(slot));
    }
    NMSImpl.sendPacketsNearby(getBukkitEntity(), current, packets);
}
Also used : Packet(net.minecraft.server.v1_10_R1.Packet) EnumItemSlot(net.minecraft.server.v1_10_R1.EnumItemSlot) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_10_R1.PacketPlayOutEntityHeadRotation) PacketPlayOutEntityEquipment(net.minecraft.server.v1_10_R1.PacketPlayOutEntityEquipment) Location(org.bukkit.Location)

Example 22 with Packet

use of com.yahoo.fs4.Packet in project Citizens2 by CitizensDev.

the class EntityHumanNPC method updatePackets.

private void updatePackets(boolean navigating) {
    if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt())
        return;
    updateCounter = 0;
    Location current = getBukkitEntity().getLocation(packetLocationCache);
    Packet<?>[] packets = new Packet[navigating ? EnumItemSlot.values().length : EnumItemSlot.values().length + 1];
    if (!navigating) {
        packets[5] = new PacketPlayOutEntityHeadRotation(this, (byte) MathHelper.d(NMSImpl.getHeadYaw(this) * 256.0F / 360.0F));
    }
    int i = 0;
    for (EnumItemSlot slot : EnumItemSlot.values()) {
        packets[i++] = new PacketPlayOutEntityEquipment(getId(), slot, getEquipment(slot));
    }
    NMSImpl.sendPacketsNearby(getBukkitEntity(), current, packets);
}
Also used : Packet(net.minecraft.server.v1_11_R1.Packet) EnumItemSlot(net.minecraft.server.v1_11_R1.EnumItemSlot) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_11_R1.PacketPlayOutEntityHeadRotation) PacketPlayOutEntityEquipment(net.minecraft.server.v1_11_R1.PacketPlayOutEntityEquipment) Location(org.bukkit.Location)

Example 23 with Packet

use of com.yahoo.fs4.Packet in project Citizens2 by CitizensDev.

the class EntityHumanNPC method updatePackets.

private void updatePackets(boolean navigating) {
    if (updateCounter++ <= Setting.PACKET_UPDATE_DELAY.asInt())
        return;
    updateCounter = 0;
    Location current = getBukkitEntity().getLocation(packetLocationCache);
    Packet<?>[] packets = new Packet[navigating ? this.inventory.armor.length : this.inventory.armor.length + 1];
    if (!navigating) {
        packets[this.inventory.armor.length] = new PacketPlayOutEntityHeadRotation(this, (byte) MathHelper.d(NMSImpl.getHeadYaw(this) * 256.0F / 360.0F));
    }
    for (int i = 0; i < this.inventory.armor.length; i++) {
        packets[i] = new PacketPlayOutEntityEquipment(getId(), i, getEquipment(i));
    }
    NMSImpl.sendPacketsNearby(getBukkitEntity(), current, packets);
}
Also used : Packet(net.minecraft.server.v1_8_R3.Packet) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation) PacketPlayOutEntityEquipment(net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment) Location(org.bukkit.Location)

Example 24 with Packet

use of com.yahoo.fs4.Packet in project jop by jop-devel.

the class Ppp method doSend.

void doSend() {
    if (reconnectRequest) {
        // System.out.print("3");
        // start over
        modemHangUp();
        modemInit();
    }
    if (disconnectRequest) {
        // stop the connection
        modemHangUp();
    }
    if (state == CONNECTED) {
        // send waiting ip packets
        if (scnt == 0) {
            // transmit buffer is free
            // use IP timeout
            globTimer = Timer.getTimeoutMs(IP_SEND);
            //
            // get a ready to send packet with source from this driver.
            //
            Packet p = PacketPool.getTxPacket(single);
            if (p != null) {
                // send one packet
                sendIp(p);
            }
        } else {
            // check sendTimer;
            if (Timer.timeout(globTimer)) {
                // System.out.print("4");
                // start over
                modemHangUp();
                modemInit();
            }
        }
    } else {
        // do the negotiation stuff
        dropIp();
        if (Timer.timeout(globTimer)) {
            /*
Dbg.intVal(state);
if (lcpAck) Dbg.wr('t'); else Dbg.wr('f');
*/
            if (scnt == 0) {
                // once every three seconds send a REQ
                if (state == MODEM_OK) {
                    makeLCP();
                    state = LCP_SENT;
                } else if (state == LCP_OK && lcpAck) {
                    makePAP();
                    state = PAP_SENT;
                //					} else if (state == PAP_OK && ipcpAck) { // wait for remote ipcp and ACK first on Linux
                } else if (state >= PAP_OK && state < CONNECTED) {
                    // ONE
                    makeIPCP();
                    state = IPCP_SENT;
                    // incremenet counter to start over when no respond
                    ++rejCnt;
                }
                // use negotiation timeout
                globTimer = Timer.getTimeoutMs(NEG_SEND);
            }
        }
    }
}
Also used : Packet(ejip123.Packet)

Example 25 with Packet

use of com.yahoo.fs4.Packet in project vespa by vespa-engine.

the class FastSearcher method searchTwoPhase.

private Result searchTwoPhase(FS4Channel channel, Query query, QueryPacket queryPacket, CacheKey cacheKey) throws IOException {
    if (isLoggingFine())
        getLogger().finest("sending query packet");
    try {
        boolean couldSend = channel.sendPacket(queryPacket);
        if (!couldSend)
            return new Result(query, ErrorMessage.createBackendCommunicationError("Could not reach '" + getName() + "'"));
    } catch (InvalidChannelException e) {
        return new Result(query, ErrorMessage.createBackendCommunicationError("Invalid channel " + getName()));
    } catch (IllegalStateException e) {
        return new Result(query, ErrorMessage.createBackendCommunicationError("Illegal state in FS4: " + e.getMessage()));
    }
    BasicPacket[] basicPackets;
    try {
        basicPackets = channel.receivePackets(query.getTimeLeft(), 1);
    } catch (ChannelTimeoutException e) {
        return new Result(query, ErrorMessage.createTimeout("Timeout while waiting for " + getName()));
    } catch (InvalidChannelException e) {
        return new Result(query, ErrorMessage.createBackendCommunicationError("Invalid channel for " + getName()));
    }
    if (basicPackets.length == 0) {
        return new Result(query, ErrorMessage.createBackendCommunicationError(getName() + " got no packets back"));
    }
    if (isLoggingFine())
        getLogger().finest("got packets " + basicPackets.length + " packets");
    ensureInstanceOf(QueryResultPacket.class, basicPackets[0], getName());
    QueryResultPacket resultPacket = (QueryResultPacket) basicPackets[0];
    if (isLoggingFine())
        getLogger().finest("got query packet. " + "docsumClass=" + query.getPresentation().getSummary());
    if (query.getPresentation().getSummary() == null)
        query.getPresentation().setSummary(getDefaultDocsumClass());
    Result result = new Result(query);
    addMetaInfo(query, queryPacket.getQueryPacketData(), resultPacket, result, false);
    addUnfilledHits(result, resultPacket.getDocuments(), false, queryPacket.getQueryPacketData(), cacheKey);
    Packet[] packets;
    PacketWrapper packetWrapper = cacheControl.lookup(cacheKey, query);
    if (packetWrapper != null) {
        cacheControl.updateCacheEntry(cacheKey, query, resultPacket);
    } else {
        if (resultPacket.getCoverageFeature() && !resultPacket.getCoverageFull()) {
        // Don't add error here, it was done in first phase
        // No check if packetWrapper already exists, since incomplete
        // first phase data won't be cached anyway.
        } else {
            packets = new Packet[1];
            packets[0] = resultPacket;
            cacheControl.cache(cacheKey, query, new DocsumPacketKey[0], packets);
        }
    }
    return result;
}
Also used : InvalidChannelException(com.yahoo.fs4.mplex.InvalidChannelException) QueryResultPacket(com.yahoo.fs4.QueryResultPacket) QueryResultPacket(com.yahoo.fs4.QueryResultPacket) QueryPacket(com.yahoo.fs4.QueryPacket) PongPacket(com.yahoo.fs4.PongPacket) BasicPacket(com.yahoo.fs4.BasicPacket) GetDocSumsPacket(com.yahoo.fs4.GetDocSumsPacket) Packet(com.yahoo.fs4.Packet) PingPacket(com.yahoo.fs4.PingPacket) BasicPacket(com.yahoo.fs4.BasicPacket) ChannelTimeoutException(com.yahoo.fs4.ChannelTimeoutException) Result(com.yahoo.search.Result)

Aggregations

Test (org.junit.Test)14 ByteBuffer (java.nio.ByteBuffer)12 BasicPacket (com.yahoo.fs4.BasicPacket)10 QueryPacket (com.yahoo.fs4.QueryPacket)10 Query (com.yahoo.search.Query)9 QueryResultPacket (com.yahoo.fs4.QueryResultPacket)8 IOException (java.io.IOException)5 ChannelTimeoutException (com.yahoo.fs4.ChannelTimeoutException)4 GetDocSumsPacket (com.yahoo.fs4.GetDocSumsPacket)4 Packet (com.yahoo.fs4.Packet)4 PacketDecoder (com.yahoo.fs4.PacketDecoder)4 DecodedPacket (com.yahoo.fs4.PacketDecoder.DecodedPacket)4 Location (org.bukkit.Location)4 DocumentInfo (com.yahoo.fs4.DocumentInfo)3 PingPacket (com.yahoo.fs4.PingPacket)3 InvalidChannelException (com.yahoo.fs4.mplex.InvalidChannelException)3 Packet (ejip123.Packet)3 BufferTooSmallException (com.yahoo.fs4.BufferTooSmallException)2 DocsumPacket (com.yahoo.fs4.DocsumPacket)2 PongPacket (com.yahoo.fs4.PongPacket)2