mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-08 23:07:46 +07:00
Removed functions from Endpoint.IdResolver
In my use-cases there should be a preexisting struct already IdResolver should just be an accessor to that struct and not a mutator
This commit is contained in:
@ -11,7 +11,5 @@ public interface Endpoint<T> {
|
|||||||
|
|
||||||
interface IdResolver<R> {
|
interface IdResolver<R> {
|
||||||
R get(int id);
|
R get(int id);
|
||||||
R put(int id, R ch);
|
|
||||||
R remove(int id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,16 +75,6 @@ public class Server implements PacketProcessor {
|
|||||||
return clients[id].channel;
|
return clients[id].channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Channel put(int id, Channel ch) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Channel remove(int id) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return ArrayUtils.toString(clients);
|
return ArrayUtils.toString(clients);
|
||||||
|
@ -4,6 +4,11 @@ import io.netty.channel.Channel;
|
|||||||
|
|
||||||
import com.riiablo.nnet.Endpoint;
|
import com.riiablo.nnet.Endpoint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Not used anymore -- prefer to use anonymous implementations of {@link Endpoint.IdResolver} which
|
||||||
|
* wrap preexisting data structures.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public class ChannelIdResolver implements Endpoint.IdResolver<Channel> {
|
public class ChannelIdResolver implements Endpoint.IdResolver<Channel> {
|
||||||
private final Channel[] channels;
|
private final Channel[] channels;
|
||||||
|
|
||||||
@ -15,16 +20,4 @@ public class ChannelIdResolver implements Endpoint.IdResolver<Channel> {
|
|||||||
public Channel get(int id) {
|
public Channel get(int id) {
|
||||||
return channels[id];
|
return channels[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Channel put(int id, Channel ch) {
|
|
||||||
Channel oldValue = channels[id];
|
|
||||||
channels[id] = ch;
|
|
||||||
return oldValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Channel remove(int id) {
|
|
||||||
return put(id, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user