当前位置: 首页>>代码示例>>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;未经允许,请勿转载。