當前位置: 首頁>>代碼示例>>Java>>正文


Java Packet.getPacketSize方法代碼示例

本文整理匯總了Java中net.minecraft.network.packet.Packet.getPacketSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Packet.getPacketSize方法的具體用法?Java Packet.getPacketSize怎麽用?Java Packet.getPacketSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.network.packet.Packet的用法示例。


在下文中一共展示了Packet.getPacketSize方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addToSendQueue

import net.minecraft.network.packet.Packet; //導入方法依賴的package包/類
/**
 * Adds the packet to the correct send queue (chunk data packets go to a separate queue).
 */
public void addToSendQueue(Packet par1Packet)
{
    if (!this.isServerTerminating)
    {
        Object object = this.sendQueueLock;

        synchronized (this.sendQueueLock)
        {
            this.sendQueueByteLength += par1Packet.getPacketSize() + 1;
            this.dataPackets.add(par1Packet);
        }
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:17,代碼來源:TcpConnection.java

示例2: sendPacket

import net.minecraft.network.packet.Packet; //導入方法依賴的package包/類
/**
 * Sends a data packet if there is one to send, or sends a chunk data packet if there is one and the counter is up,
 * or does nothing.
 */
private boolean sendPacket()
{
    boolean flag = false;

    try
    {
        Packet packet;
        int i;
        int[] aint;

        if (this.field_74468_e == 0 || !this.dataPackets.isEmpty() && MinecraftServer.getSystemTimeMillis() - ((Packet)this.dataPackets.get(0)).creationTimeMillis >= (long)this.field_74468_e)
        {
            packet = this.func_74460_a(false);

            if (packet != null)
            {
                Packet.writePacket(packet, this.socketOutputStream);

                if (packet instanceof Packet252SharedKey && !this.isOutputEncrypted)
                {
                    if (!this.theNetHandler.isServerHandler())
                    {
                        this.sharedKeyForEncryption = ((Packet252SharedKey)packet).getSharedKey();
                    }

                    this.encryptOuputStream();
                }

                aint = field_74467_d;
                i = packet.getPacketId();
                aint[i] += packet.getPacketSize() + 1;
                flag = true;
            }
        }

        if (this.chunkDataPacketsDelay-- <= 0 && (this.field_74468_e == 0 || !this.chunkDataPackets.isEmpty() && MinecraftServer.getSystemTimeMillis() - ((Packet)this.chunkDataPackets.get(0)).creationTimeMillis >= (long)this.field_74468_e))
        {
            packet = this.func_74460_a(true);

            if (packet != null)
            {
                Packet.writePacket(packet, this.socketOutputStream);
                aint = field_74467_d;
                i = packet.getPacketId();
                aint[i] += packet.getPacketSize() + 1;
                this.chunkDataPacketsDelay = 0;
                flag = true;
            }
        }

        return flag;
    }
    catch (Exception exception)
    {
        if (!this.isTerminating)
        {
            this.onNetworkError(exception);
        }

        return false;
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:67,代碼來源:TcpConnection.java

示例3: readPacket

import net.minecraft.network.packet.Packet; //導入方法依賴的package包/類
/**
 * Reads a single packet from the input stream and adds it to the read queue. If no packet is read, it shuts down
 * the network.
 */
private boolean readPacket()
{
    boolean flag = false;

    try
    {
        Packet packet = Packet.readPacket(this.tcpConLogAgent, this.socketInputStream, this.theNetHandler.isServerHandler(), this.networkSocket);

        if (packet != null)
        {
            if (packet instanceof Packet252SharedKey && !this.isInputBeingDecrypted)
            {
                if (this.theNetHandler.isServerHandler())
                {
                    this.sharedKeyForEncryption = ((Packet252SharedKey)packet).getSharedKey(this.field_74463_A);
                }

                this.decryptInputStream();
            }

            int[] aint = field_74470_c;
            int i = packet.getPacketId();
            aint[i] += packet.getPacketSize() + 1;

            if (!this.isServerTerminating)
            {
                if (packet.canProcessAsync() && this.theNetHandler.canProcessPacketsAsync())
                {
                    this.field_74490_x = 0;
                    packet.processPacket(this.theNetHandler);
                }
                else
                {
                    this.readPackets.add(packet);
                }
            }

            flag = true;
        }
        else
        {
            this.networkShutdown("disconnect.endOfStream", new Object[0]);
        }

        return flag;
    }
    catch (Exception exception)
    {
        if (!this.isTerminating)
        {
            this.onNetworkError(exception);
        }

        return false;
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:61,代碼來源:TcpConnection.java


注:本文中的net.minecraft.network.packet.Packet.getPacketSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。