mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 08:50:51 +01:00
Add reliability to packets and actually clear the message buffer.
This commit is contained in:
parent
f9d81ea198
commit
ee5a97bbae
@ -3726,6 +3726,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
|
||||
public void sendComposer(ServerMessage message) {
|
||||
message.retain();
|
||||
|
||||
try {
|
||||
for (Habbo habbo : this.getHabbos()) {
|
||||
if (habbo.getClient() == null) {
|
||||
this.removeHabbo(habbo, true);
|
||||
@ -3734,28 +3737,49 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendComposerToHabbosWithRights(ServerMessage message) {
|
||||
message.retain();
|
||||
|
||||
try {
|
||||
for (Habbo habbo : this.getHabbos()) {
|
||||
if (this.hasRights(habbo)) {
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
|
||||
public void petChat(ServerMessage message) {
|
||||
message.retain();
|
||||
|
||||
try {
|
||||
for (Habbo habbo : this.getHabbos()) {
|
||||
if (!habbo.getHabboStats().ignorePets)
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
|
||||
public void botChat(ServerMessage message) {
|
||||
message.retain();
|
||||
|
||||
try {
|
||||
for (Habbo habbo : this.getHabbos()) {
|
||||
if (!habbo.getHabboStats().ignoreBots)
|
||||
habbo.getClient().sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
message.release();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadRights(Connection connection) {
|
||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.rooms;
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
|
||||
@ -310,9 +311,17 @@ public class RoomTrade {
|
||||
}
|
||||
|
||||
public void sendMessageToUsers(MessageComposer message) {
|
||||
ServerMessage messageComposed = message.compose();
|
||||
|
||||
messageComposed.retain();
|
||||
|
||||
try {
|
||||
for (RoomTradeUser roomTradeUser : this.users) {
|
||||
roomTradeUser.getHabbo().getClient().sendResponse(message);
|
||||
}
|
||||
} finally {
|
||||
messageComposed.release();
|
||||
}
|
||||
}
|
||||
|
||||
public List<RoomTradeUser> getRoomTradeUsers() {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.eu.habbo.messages;
|
||||
|
||||
import com.eu.habbo.util.DebugUtils;
|
||||
import com.eu.habbo.util.PacketUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
@ -194,23 +193,13 @@ public class ServerMessage implements ReferenceCounted {
|
||||
|
||||
@Override
|
||||
public ReferenceCounted retain() {
|
||||
int result = this.refs.incrementAndGet();
|
||||
|
||||
if (this.header == 1167 || this.header == 2024 || this.header == 2505) {
|
||||
System.out.printf("retain Packet: %d Count: %d From: %s%n", this.header, result, DebugUtils.getCallerCallerStacktrace());
|
||||
}
|
||||
|
||||
this.refs.incrementAndGet();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReferenceCounted retain(int i) {
|
||||
int result = this.refs.addAndGet(i);
|
||||
|
||||
if (this.header == 1167 || this.header == 2024 || this.header == 2505) {
|
||||
System.out.printf("retain Packet: %d Count: %d From: %s%n", this.header, result, DebugUtils.getCallerCallerStacktrace());
|
||||
}
|
||||
|
||||
this.refs.addAndGet(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -232,17 +221,12 @@ public class ServerMessage implements ReferenceCounted {
|
||||
@Override
|
||||
public boolean release(int i) {
|
||||
int value = this.refs.addAndGet(-i);
|
||||
|
||||
if (this.header == 1167 || this.header == 2024 || this.header == 2505) {
|
||||
System.out.printf("release Packet: %d Count: %d From: %s%n", this.header, value, DebugUtils.getCallerCallerStacktrace());
|
||||
}
|
||||
|
||||
if (value < 0) {
|
||||
throw new IllegalReferenceCountException("Decremented below 0 (packet " + this.header + " value " + value + ").");
|
||||
}
|
||||
|
||||
if (value == 0) {
|
||||
this.channelBuffer.release();
|
||||
this.channelBuffer.release(this.channelBuffer.refCnt());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user