Package com.ngt.jopenmetaverse.shared.protocol

Examples of com.ngt.jopenmetaverse.shared.protocol.Packet


        /// <summary>Process an incoming packet and raise the appropriate events</summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The EventArgs object containing the packet data</param>
        private void TerminateFriendshipHandler(Object sender, PacketReceivedEventArgs e)
        {
            Packet packet = e.getPacket();
            TerminateFriendshipPacket itsOver = (TerminateFriendshipPacket)packet;
            String name = "";

            if (FriendList.containsKey(itsOver.ExBlock.OtherID))
            {
View Full Code Here


        /// <summary>Process an incoming packet and raise the appropriate events</summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The EventArgs object containing the packet data</param>
        protected void OnlineNotificationHandler(Object sender, PacketReceivedEventArgs e)
        {
            Packet packet = e.getPacket();
            if (packet.Type == PacketType.OnlineNotification)
            {
                OnlineNotificationPacket notification = ((OnlineNotificationPacket)packet);

                for (OnlineNotificationPacket.AgentBlockBlock block : notification.AgentBlock)
View Full Code Here

        /// <summary>Process an incoming packet and raise the appropriate events</summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The EventArgs object containing the packet data</param>
        protected void OfflineNotificationHandler(Object sender, PacketReceivedEventArgs e)
        {
            Packet packet = e.getPacket();
            if (packet.Type == PacketType.OfflineNotification)
            {
                OfflineNotificationPacket notification = (OfflineNotificationPacket)packet;

                for (OfflineNotificationPacket.AgentBlockBlock block : notification.AgentBlock)
View Full Code Here

        /// <summary>Process an incoming packet and raise the appropriate events</summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The EventArgs object containing the packet data</param>
        private void ChangeUserRightsHandler(Object sender, PacketReceivedEventArgs e)
        {
            Packet packet = e.getPacket();
            if (packet.Type == PacketType.ChangeUserRights)
            {
                FriendInfo friend;
                ChangeUserRightsPacket rights = (ChangeUserRightsPacket)packet;
View Full Code Here

        /// <param name="e">The EventArgs object containing the packet data</param>
        public void OnFindAgentReplyHandler(Object sender, PacketReceivedEventArgs e)
        {
            if (onFriendFoundReply != null)
            {
                Packet packet = e.getPacket();
                FindAgentPacket reply = (FindAgentPacket)packet;

                float[] xy = new float[2];
                UUID prey = reply.AgentBlock.Prey;
                BigInteger regionHandle = Helpers.GlobalPosToRegionHandle((float)reply.LocationBlock[0].GlobalX,
View Full Code Here

  }

  @Override
  protected void PacketReceived(UDPPacketBuffer buffer)
  {
    Packet packet = null;

    // Check if this packet came from the server we expected it to come from
    if (!remoteEndPoint.getAddress().equals(((InetSocketAddress)buffer.getRemoteEndPoint()).getAddress()))
    {
      JLogger.warn("Received " + buffer.getDataLength() + " bytes of data from unrecognized source " +
          ((InetSocketAddress)buffer.getRemoteEndPoint()).toString());
      return;
    }

    // Update the disconnect flag so this sim doesn't time out
    DisconnectCandidate = false;

    //region Packet Decoding

    int[] packetEnd = new int[]{buffer.getDataLength() - 1};

    try
    {
      packet = Packet.BuildPacket(buffer.getData(), packetEnd,
          // Only allocate a buffer for zerodecoding if the packet is zerocoded
          ((buffer.getData()[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[8192] : null);
    }
    catch (MalformedDataException e)
    {
      JLogger.error(String.format("Malformed data, cannot parse packet:\n%s\nException: %s",
          Utils.bytesToHexDebugString(buffer.getData(), buffer.getDataLength(), null),
          Utils.getExceptionStackTraceAsString(e)));
    }

    // Fail-safe check
    if (packet == null)
    {
      JLogger.warn("Couldn't build a message from the incoming data");
      return;
    }

//    Interlocked.Add(ref Stats.RecvBytes, buffer.DataLength);
//    Interlocked.Increment(ref Stats.RecvPackets);
    Stats.RecvBytes.addAndGet(buffer.getDataLength());
    Stats.RecvPackets.incrementAndGet();

    //endregion Packet Decoding

    if (packet.header.Resent)
//      Interlocked.Increment(ref Stats.ReceivedResends);
    Stats.ReceivedResends.incrementAndGet();
    //region ACK Receiving

    // Handle appended ACKs
    if (packet.header.AppendedAcks && packet.header.AckList != null)
    {
      synchronized (NeedAck)
      {
        for (int i = 0; i < packet.header.AckList.length; i++)
        {
          if (NeedAck.containsKey(packet.header.AckList[i])
              && NeedAck.get(packet.header.AckList[i]).Type.equals(PacketType.UseCircuitCode))
          {
            GotUseCircuitCodeAck.set();
          }
          NeedAck.remove(packet.header.AckList[i]);
        }
      }
    }

    // Handle PacketAck packets
    if (packet.Type == PacketType.PacketAck)
    {
      PacketAckPacket ackPacket = (PacketAckPacket)packet;

      synchronized (NeedAck)
      {
        for (int i = 0; i < ackPacket.Packets.length; i++)
        {
          if (NeedAck.containsKey(ackPacket.Packets[i].ID)
              && NeedAck.get(ackPacket.Packets[i].ID).Type.equals(PacketType.UseCircuitCode))
          {
            GotUseCircuitCodeAck.set();
          }
          NeedAck.remove(ackPacket.Packets[i].ID);
        }
      }
    }

    //endregion ACK Receiving

    if (packet.header.Reliable)
    {
      //region ACK Sending

      // Add this packet to the list of ACKs that need to be sent out
      //uint
      long sequence = (long)packet.header.Sequence;
      PendingAcks.offer(sequence);

      // Send out ACKs if we have a lot of them
      if (PendingAcks.size() >= Client.settings.MAX_PENDING_ACKS)
        SendAcks();

      //endregion ACK Sending

      // Check the archive of received packet IDs to see whether we already received this packet
      if (!PacketArchive.offer(packet.header.Sequence))
      {
        if (packet.header.Resent)
          JLogger.debug("Received a resend of already processed packet #" + packet.header.Sequence + ", type: " + packet.Type);
        else
          JLogger.warn("Received a duplicate (not marked as resend) of packet #" + packet.header.Sequence + ", type: " + packet.Type);

        // Avoid firing a callback twice for the same packet
        return;
      }
    }

    //region Inbox Insertion

    NetworkManager.IncomingPacket incomingPacket = new NetworkManager.IncomingPacket();
    incomingPacket.simulator = this;
    incomingPacket.packet = packet;

    Network.PacketInbox.offer(incomingPacket);

    //endregion Inbox Insertion

    //region Stats Tracking
    if (Client.settings.TRACK_UTILIZATION)
    {
      Client.stats.Update(packet.Type.toString(),
          UtilizationStatistics.Type.Packet, 0, packet.getLength());
    }
    //endregion
  }
View Full Code Here

        /// <param name="e">The EventArgs object containing the packet data</param>
        protected void AgentDropGroupHandler(Object sender, PacketReceivedEventArgs e)
        {
            if (onGroupDropped != null)
            {
                Packet packet = e.getPacket();
                onGroupDropped.raiseEvent(new GroupDroppedEventArgs(((AgentDropGroupPacket)packet).AgentData.GroupID));
            }
        }
View Full Code Here

        /// <param name="e">The EventArgs object containing the packet data</param>
        protected void GroupProfileReplyHandler(Object sender, PacketReceivedEventArgs e) throws UnsupportedEncodingException
        {           
            if (onGroupProfile != null)
            {
                Packet packet = e.getPacket();
                GroupProfileReplyPacket profile = (GroupProfileReplyPacket)packet;
                Group group = new Group();

                group.ID = profile.GroupData.GroupID;
                group.AllowPublish = profile.GroupData.AllowPublish;
View Full Code Here

        /// <param name="e">The EventArgs object containing the packet data</param>
        protected void GroupNoticesListReplyHandler(Object sender, PacketReceivedEventArgs e) throws UnsupportedEncodingException
        {
            if (onGroupNoticesListReply != null)
            {
                Packet packet = e.getPacket();
                GroupNoticesListReplyPacket reply = (GroupNoticesListReplyPacket)packet;

                List<GroupNoticesListEntry> notices = new ArrayList<GroupNoticesListEntry>();

                for(GroupNoticesListReplyPacket.DataBlock entry : reply.Data)
View Full Code Here

        /// <param name="e">The EventArgs object containing the packet data</param>
        protected void GroupTitlesReplyHandler(Object sender, PacketReceivedEventArgs e) throws UnsupportedEncodingException
        {
            if (onGroupTitlesReply != null)
            {
                Packet packet = e.getPacket();
                GroupTitlesReplyPacket titles = (GroupTitlesReplyPacket)packet;
                Map<UUID, GroupTitle> groupTitleCache = new HashMap<UUID, GroupTitle>();

                for(GroupTitlesReplyPacket.GroupDataBlock block : titles.GroupData)
                {
View Full Code Here

TOP

Related Classes of com.ngt.jopenmetaverse.shared.protocol.Packet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.