public override void Handle(NecClient client, NecPacket packet)
        {
            uint partyInstanceId = packet.data.ReadUInt32();

            _Logger.Debug($"character {client.character.name} accepted invite to party ID {partyInstanceId}");

            IBuffer res = BufferProvider.Provide();

            res.WriteUInt32(0); //error check?
            router.Send(client, (ushort)AreaPacketId.recv_party_accept_to_invite_r, res, ServerType.Area);

            Party myParty = server.instances.GetInstance(partyInstanceId) as Party;

            if (!myParty.partyMembers.Contains(client))
            {
                myParty.Join(client);
            }

            foreach (NecClient partyClient in myParty.partyMembers)
            {
                //Sanity check.  Who is in the party List at the time of Accepting the invite?
                _Logger.Debug(
                    $"my party with instance ID {myParty.instanceId} contains members {partyClient.character.name}");
                List <NecClient> disposableList = new List <NecClient>();
                foreach (NecClient disposablePartyClient in myParty.partyMembers)
                {
                    disposableList.Add(disposablePartyClient);
                    _Logger.Debug($"Added {disposablePartyClient.character.name} to disposable list");
                }

                RecvPartyNotifyAddMember recvPartyNotifyAddMember = new RecvPartyNotifyAddMember(partyClient);
                router.Send(recvPartyNotifyAddMember, disposableList);

                _Logger.Debug($"Adding member {partyClient.character.name} to Roster ");
            }

            client.character.partyId = myParty.instanceId;

            RecvPartyNotifyEstablish recvPartyNotifyEstablish = new RecvPartyNotifyEstablish(client, myParty);

            router.Send(recvPartyNotifyEstablish, client); // Only establish the party for the acceptee. everyone else is already established.

            RecvCharaBodyNotifyPartyJoin recvCharaBodyNotifyPartyJoin = new RecvCharaBodyNotifyPartyJoin(client.character.instanceId, myParty.instanceId, myParty.partyType);

            router.Send(client.map, recvCharaBodyNotifyPartyJoin); //Only send the Join Notify of the Accepting Client to the Map.  Existing members already did that when they joined.

            RecvCharaNotifyPartyJoin recvCharaNotifyPartyJoin = new RecvCharaNotifyPartyJoin(client.character.instanceId, myParty.instanceId, myParty.partyType);

            router.Send(recvCharaNotifyPartyJoin, client); //Only send the Join of the Accepting Client to the Accepting Client.
        }
        public override void Handle(NecClient client, NecPacket packet)
        {
            /*int32, party type: 1 = open, 0 = closed
             * int32, normal item distribution: 1 = random, 0 = do not distribute
             * int32, rare item distribution: 1 = draw, 0 = do not distribute
             * int32, target client(character) id*/

            int  partyType        = packet.data.ReadInt32();
            int  normItemDist     = packet.data.ReadInt32();
            int  rareItemDist     = packet.data.ReadInt32();
            uint targetInstanceId = packet.data.ReadUInt32();

            Party myFirstParty = new Party();

            server.instances.AssignInstance(myFirstParty);
            myFirstParty.partyType      = partyType;
            myFirstParty.normalItemDist = normItemDist;
            myFirstParty.rareItemDist   = rareItemDist;
            myFirstParty.targetClientId = targetInstanceId;
            myFirstParty.Join(client);
            myFirstParty.partyLeaderId = client.character.instanceId;
            client.character.partyId   = myFirstParty.instanceId;

            RecvPartyNotifyEstablish recvPartyNotifyEstablish = new RecvPartyNotifyEstablish(client, myFirstParty);

            router.Send(recvPartyNotifyEstablish, client); // Only establish the party for the acceptee. everyone else is already established.

            RecvCharaBodyNotifyPartyJoin recvCharaBodyNotifyPartyJoin = new RecvCharaBodyNotifyPartyJoin(client.character.instanceId, myFirstParty.instanceId, myFirstParty.partyType);

            router.Send(client.map, recvCharaBodyNotifyPartyJoin); //Only send the Join Notify of the Accepting Client to the Map.  Existing members already did that when they joined.

            RecvCharaNotifyPartyJoin recvCharaNotifyPartyJoin = new RecvCharaNotifyPartyJoin(client.character.instanceId, myFirstParty.instanceId, myFirstParty.partyType);

            router.Send(recvCharaNotifyPartyJoin, client); //Only send the Join of the Accepting Client to the Accepting Client.

            if (targetInstanceId != 0)
            {
                NecClient             targetClient          = server.clients.GetByCharacterInstanceId(targetInstanceId);
                RecvPartyNotifyInvite recvPartyNotifyInvite = new RecvPartyNotifyInvite(targetClient, myFirstParty);
                router.Send(recvPartyNotifyInvite, targetClient);
            }

            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0);
            router.Send(client, (ushort)AreaPacketId.recv_party_establish_r, res, ServerType.Area);
        }