mirror of
https://github.com/Rabiator1/SWG-Station-Chat.git
synced 2026-01-16 20:04:20 -05:00
Add files via upload
This commit is contained in:
50
src/main/java/chat/ChatApiClient.java
Normal file
50
src/main/java/chat/ChatApiClient.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericMessage;
|
||||
import chat.util.ChatUnicodeString;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
|
||||
public class ChatApiClient {
|
||||
|
||||
private Channel channel;
|
||||
private ChatUnicodeString address;
|
||||
|
||||
public ChatApiClient(Channel channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public Channel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(Channel channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public void send(ByteBuffer byteBuffer) {
|
||||
ByteBuf buf = GenericMessage.alloc.buffer(byteBuffer.capacity()).order(ByteOrder.LITTLE_ENDIAN);
|
||||
byteBuffer.flip();
|
||||
buf.writeBytes(byteBuffer);
|
||||
channel.writeAndFlush(buf);
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(ChatUnicodeString address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public int getNodeId() {
|
||||
if(address != null)
|
||||
return address.getString().hashCode();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
3187
src/main/java/chat/ChatApiServer.java
Normal file
3187
src/main/java/chat/ChatApiServer.java
Normal file
File diff suppressed because it is too large
Load Diff
504
src/main/java/chat/ChatApiTcpHandler.java
Normal file
504
src/main/java/chat/ChatApiTcpHandler.java
Normal file
@@ -0,0 +1,504 @@
|
||||
package chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.management.timer.Timer;
|
||||
|
||||
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import chat.protocol.GenericMessage;
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.protocol.request.RAddBan;
|
||||
import chat.protocol.request.RAddFriend;
|
||||
import chat.protocol.request.RAddIgnore;
|
||||
import chat.protocol.request.RAddInvite;
|
||||
import chat.protocol.request.RAddModerator;
|
||||
import chat.protocol.request.RCreateRoom;
|
||||
import chat.protocol.request.RDestroyRoom;
|
||||
import chat.protocol.request.RDestroyAvatar;
|
||||
import chat.protocol.request.REnterRoom;
|
||||
import chat.protocol.request.RFailoverReloginAvatar;
|
||||
import chat.protocol.request.RFailoverRecreateRoom;
|
||||
import chat.protocol.request.RFriendStatus;
|
||||
import chat.protocol.request.RGetAnyAvatar;
|
||||
import chat.protocol.request.RGetPersistentHeaders;
|
||||
import chat.protocol.request.RGetPersistentMessage;
|
||||
import chat.protocol.request.RGetRoom;
|
||||
import chat.protocol.request.RGetRoomSummaries;
|
||||
import chat.protocol.request.RIgnoreStatus;
|
||||
import chat.protocol.request.RKickAvatar;
|
||||
import chat.protocol.request.RLeaveRoom;
|
||||
import chat.protocol.request.RLoginAvatar;
|
||||
import chat.protocol.request.RLogoutAvatar;
|
||||
import chat.protocol.request.RRegistrarGetChatServer;
|
||||
import chat.protocol.request.RRemoveBan;
|
||||
import chat.protocol.request.RRemoveFriend;
|
||||
import chat.protocol.request.RRemoveIgnore;
|
||||
import chat.protocol.request.RRemoveInvite;
|
||||
import chat.protocol.request.RRemoveModerator;
|
||||
import chat.protocol.request.RSendApiVersion;
|
||||
import chat.protocol.request.RSendInstantMessage;
|
||||
import chat.protocol.request.RSendPersistentMessage;
|
||||
import chat.protocol.request.RSendRoomMessage;
|
||||
import chat.protocol.request.RSetAvatarAttributes;
|
||||
import chat.protocol.request.RUpdatePersistentMessage;
|
||||
import chat.protocol.request.RUpdatePersistentMessages;
|
||||
import chat.protocol.response.ResFriendStatus;
|
||||
import chat.protocol.response.ResGetPersistentHeaders;
|
||||
import chat.protocol.response.ResGetPersistentMessage;
|
||||
import chat.protocol.response.ResIgnoreStatus;
|
||||
import chat.protocol.response.ResRegistrarGetChatServer;
|
||||
import chat.protocol.response.ResSendApiVersion;
|
||||
import chat.protocol.response.ResSetAvatarAttributes;
|
||||
import chat.protocol.response.ResUpdatePersistentMessage;
|
||||
import chat.protocol.response.ResUpdatePersistentMessages;
|
||||
import chat.protocol.response.ResponseResult;
|
||||
import chat.protocol.message.MDestroyRoom;
|
||||
import chat.protocol.message.MLeaveRoom;
|
||||
import chat.protocol.message.MEnterRoom;
|
||||
import chat.protocol.message.MFriendLogin;
|
||||
import chat.protocol.message.MFriendLogout;
|
||||
import chat.util.ChatUnicodeString;
|
||||
import chat.util.PersistentMessageStatus;
|
||||
import gnu.trove.map.TShortObjectMap;
|
||||
import gnu.trove.map.hash.TShortObjectHashMap;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
public class ChatApiTcpHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
private TShortObjectMap<PacketHandler> packetTypes;
|
||||
private static Logger logger = LogManager.getLogger(ChatApiTcpHandler.class);
|
||||
private ChatApiServer server = ChatApiServer.getInstance();
|
||||
|
||||
|
||||
public ChatApiTcpHandler() {
|
||||
packetTypes = new TShortObjectHashMap<>();
|
||||
insertPacketHandlers();
|
||||
}
|
||||
|
||||
// TODO: change this entire handler system to a dependency injection based system
|
||||
private void insertPacketHandlers() {
|
||||
packetTypes.put(GenericRequest.REQUEST_REGISTRAR_GETCHATSERVER, (cluster, packet) -> {
|
||||
RRegistrarGetChatServer req = new RRegistrarGetChatServer();
|
||||
req.deserialize(packet);
|
||||
String hostname = server.getConfig().getString("hostname");
|
||||
int port = server.getConfig().getInt("gatewayPort");
|
||||
ResRegistrarGetChatServer res = new ResRegistrarGetChatServer();
|
||||
res.setTrack(req.getTrack());
|
||||
res.setHostname(new ChatUnicodeString(hostname));
|
||||
res.setPort((short) port);
|
||||
res.setResult(ResponseResult.CHATRESULT_SUCCESS);
|
||||
server.getScheduler().schedule(() -> cluster.send(res.serialize()), 15, TimeUnit.SECONDS); // fix bug where server wouldnt create system rooms
|
||||
logger.info("Registrar recieved GetChatServer requested");
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_SETAPIVERSION, (cluster, packet) -> {
|
||||
int version = server.getConfig().getInt("apiVersion");
|
||||
RSendApiVersion req = new RSendApiVersion();
|
||||
req.deserialize(packet);
|
||||
ResSendApiVersion res = new ResSendApiVersion();
|
||||
res.setTrack(req.getTrack());
|
||||
res.setVersion(version);
|
||||
if(version == req.getVersion()) {
|
||||
res.setResult(ResponseResult.CHATRESULT_SUCCESS);
|
||||
} else {
|
||||
res.setResult(ResponseResult.CHATRESULT_WRONGCHATSERVERFORREQUEST);
|
||||
}
|
||||
cluster.send(res.serialize());
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_LOGINAVATAR, (cluster, packet) -> {
|
||||
RLoginAvatar req = new RLoginAvatar();
|
||||
req.deserialize(packet);
|
||||
if(cluster.getAddress() == null) // store the clusters address at first login since api client doesnt send us any address information otherwise
|
||||
cluster.setAddress(req.getAddress());
|
||||
//System.out.println(req.getAddress().getString() + "+" + req.getName().getString());
|
||||
//System.out.println(req.getLoginLocation().getString());
|
||||
//System.out.println("Attributes: " + req.getLoginAttributes());
|
||||
server.handleLoginAvatar(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_SENDINSTANTMESSAGE, (cluster, packet) -> {
|
||||
RSendInstantMessage req = new RSendInstantMessage();
|
||||
req.deserialize(packet);
|
||||
server.handleInstantMessage(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericMessage.MESSAGE_DESTROYROOM, (cluster, packet) -> {
|
||||
MDestroyRoom msg = new MDestroyRoom();
|
||||
msg.deserialize(packet);
|
||||
//System.out.println("Got MESSAGE for MDESTROYROOM");
|
||||
//server.handleInstantMessage(cluster, msg);
|
||||
});
|
||||
packetTypes.put(GenericMessage.MESSAGE_LEAVEROOM, (cluster, packet) -> {
|
||||
MLeaveRoom msg = new MLeaveRoom();
|
||||
msg.deserialize(packet);
|
||||
//System.out.println("Got MESSAGE for MLEAVEROOM");
|
||||
//server.handleInstantMessage(cluster, msg);
|
||||
});
|
||||
packetTypes.put(GenericMessage.MESSAGE_ENTERROOM, (cluster, packet) -> {
|
||||
MEnterRoom msg = new MEnterRoom();
|
||||
msg.deserialize(packet);
|
||||
//System.out.println("Got MESSAGE for MENTERROOM");
|
||||
//server.handleInstantMessage(cluster, msg);
|
||||
});
|
||||
packetTypes.put(GenericMessage.MESSAGE_FRIENDLOGIN, (cluster, packet) -> {
|
||||
MFriendLogin msg = new MFriendLogin();
|
||||
msg.deserialize(packet);
|
||||
//System.out.println("Got MESSAGE for MFRIENDLOGIN");
|
||||
//server.handleInstantMessage(cluster, msg);
|
||||
});
|
||||
packetTypes.put(GenericMessage.MESSAGE_FRIENDLOGOUT, (cluster, packet) -> {
|
||||
MFriendLogout msg = new MFriendLogout();
|
||||
msg.deserialize(packet);
|
||||
//System.out.println("Got MESSAGE for MFRIENDLOGOUT");
|
||||
//server.handleInstantMessage(cluster, msg);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_LOGOUTAVATAR, (cluster, packet) -> {
|
||||
RLogoutAvatar req = new RLogoutAvatar();
|
||||
//System.out.println("Got Request for Logout");
|
||||
req.deserialize(packet);
|
||||
server.handleLogoutAvatar(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_DESTROYAVATAR, (cluster, packet) -> {
|
||||
RDestroyAvatar req = new RDestroyAvatar();
|
||||
req.deserialize(packet);
|
||||
server.handleDestroyAvatar(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_KICKAVATAR, (cluster, packet) -> {
|
||||
RKickAvatar req = new RKickAvatar();
|
||||
//System.out.println("got kick in handler");
|
||||
req.deserialize(packet);
|
||||
server.handleKickAvatar(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_ADDINVITE, (cluster, packet) -> {
|
||||
RAddInvite req = new RAddInvite();
|
||||
//System.out.println("got addinvite in handler");
|
||||
req.deserialize(packet);
|
||||
server.handleAddInvite(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_REMOVEINVITE, (cluster, packet) -> {
|
||||
RRemoveInvite req = new RRemoveInvite();
|
||||
//System.out.println("got remove invite in handler");
|
||||
req.deserialize(packet);
|
||||
server.handleRemoveInvite(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_ADDBAN, (cluster, packet) -> {
|
||||
RAddBan req = new RAddBan();
|
||||
req.deserialize(packet);
|
||||
//System.out.println("got ban in handler " + req.toString());
|
||||
server.handleAddBan(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_REMOVEBAN, (cluster, packet) -> {
|
||||
RRemoveBan req = new RRemoveBan();
|
||||
req.deserialize(packet);
|
||||
server.handleRemoveBan(cluster, req);
|
||||
});
|
||||
|
||||
packetTypes.put(GenericRequest.REQUEST_SETAVATARATTRIBUTES, (cluster, packet) -> {
|
||||
RSetAvatarAttributes req = new RSetAvatarAttributes();
|
||||
req.deserialize(packet);
|
||||
ResSetAvatarAttributes res = new ResSetAvatarAttributes();
|
||||
res.setTrack(req.getTrack());
|
||||
ChatAvatar avatar = server.getAvatarById(req.getAvatarId());
|
||||
if(avatar == null) {
|
||||
res.setResult(ResponseResult.CHATRESULT_DESTAVATARDOESNTEXIST);
|
||||
cluster.send(res.serialize());
|
||||
} else {
|
||||
res.setResult(ResponseResult.CHATRESULT_SUCCESS);
|
||||
avatar.setAttributes(req.getAvatarAttributes());
|
||||
res.setAvatar(avatar);
|
||||
cluster.send(res.serialize());
|
||||
server.persistAvatar(avatar, true);
|
||||
}
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_GETAVATAR, (cluster, packet) -> {}); // not used for SWG
|
||||
packetTypes.put(GenericRequest.REQUEST_GETANYAVATAR, (cluster, packet) -> {
|
||||
RGetAnyAvatar req = new RGetAnyAvatar();
|
||||
req.deserialize(packet);
|
||||
server.handleGetAnyAvatar(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_SENDPERSISTENTMESSAGE, (cluster, packet) -> {
|
||||
//System.out.println("recv mail");
|
||||
RSendPersistentMessage req = new RSendPersistentMessage();
|
||||
req.deserialize(packet);
|
||||
server.handleSendPersistentMessage(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_GETPERSISTENTMESSAGE, (cluster, packet) -> {
|
||||
RGetPersistentMessage req = new RGetPersistentMessage();
|
||||
req.deserialize(packet);
|
||||
ResGetPersistentMessage res = new ResGetPersistentMessage();
|
||||
res.setTrack(req.getTrack());
|
||||
ChatAvatar avatar = server.getAvatarById(req.getSrcAvatarId());
|
||||
if(avatar == null) {
|
||||
res.setResult(ResponseResult.CHATRESULT_SRCAVATARDOESNTEXIST);
|
||||
cluster.send(res.serialize());
|
||||
return;
|
||||
}
|
||||
PersistentMessage pm = avatar.getPm(req.getMessageId());
|
||||
if(pm == null) {
|
||||
res.setResult(ResponseResult.CHATRESULT_PMSGNOTFOUND);
|
||||
cluster.send(res.serialize());
|
||||
return;
|
||||
}
|
||||
if(pm.getStatus() == PersistentMessageStatus.NEW)
|
||||
pm.setStatus(PersistentMessageStatus.READ);
|
||||
res.setPm(pm);
|
||||
res.setResult(ResponseResult.CHATRESULT_SUCCESS);
|
||||
cluster.send(res.serialize());
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_UPDATEPERSISTENTMESSAGE, (cluster, packet) -> {
|
||||
RUpdatePersistentMessage req = new RUpdatePersistentMessage();
|
||||
req.deserialize(packet);
|
||||
//System.out.println("got request for updatepersistentmessage");
|
||||
ResUpdatePersistentMessage res = new ResUpdatePersistentMessage();
|
||||
res.setTrack(req.getTrack());
|
||||
ChatAvatar avatar = server.getAvatarById(req.getSrcAvatarId());
|
||||
if(avatar == null) {
|
||||
res.setResult(ResponseResult.CHATRESULT_SRCAVATARDOESNTEXIST);
|
||||
cluster.send(res.serialize());
|
||||
return;
|
||||
}
|
||||
PersistentMessage pm = avatar.getPm(req.getMessageId());
|
||||
if(pm == null) {
|
||||
res.setResult(ResponseResult.CHATRESULT_PMSGNOTFOUND);
|
||||
cluster.send(res.serialize());
|
||||
return;
|
||||
}
|
||||
pm.setStatus(req.getStatus());
|
||||
if(pm.getStatus() == PersistentMessageStatus.DELETED)
|
||||
server.destroyPersistentMessage(avatar, pm);
|
||||
res.setResult(ResponseResult.CHATRESULT_SUCCESS);
|
||||
cluster.send(res.serialize());
|
||||
server.persistAvatar(avatar, true);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_UPDATEPERSISTENTMESSAGES, (cluster, packet) -> {
|
||||
RUpdatePersistentMessages req = new RUpdatePersistentMessages();
|
||||
req.deserialize(packet);
|
||||
ResUpdatePersistentMessages res = new ResUpdatePersistentMessages();
|
||||
res.setTrack(req.getTrack());
|
||||
ChatAvatar avatar = server.getAvatarById(req.getSrcAvatarId());
|
||||
if(avatar == null) {
|
||||
res.setResult(ResponseResult.CHATRESULT_SRCAVATARDOESNTEXIST);
|
||||
cluster.send(res.serialize());
|
||||
return;
|
||||
}
|
||||
Collection<PersistentMessage> pmList = avatar.getPmList().valueCollection();
|
||||
for(PersistentMessage pm : pmList) {
|
||||
if(pm.getStatus() == req.getCurrentStatus()) {
|
||||
pm.setStatus(req.getNewStatus());
|
||||
if(pm.getStatus() == PersistentMessageStatus.DELETED)
|
||||
server.destroyPersistentMessage(avatar, pm);
|
||||
}
|
||||
}
|
||||
res.setResult(ResponseResult.CHATRESULT_SUCCESS);
|
||||
cluster.send(res.serialize());
|
||||
server.persistAvatar(avatar, true);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_GETPERSISTENTHEADERS, (cluster, packet) -> {
|
||||
//System.out.println("got request for headers");
|
||||
RGetPersistentHeaders req = new RGetPersistentHeaders();
|
||||
req.deserialize(packet);
|
||||
ResGetPersistentHeaders res = new ResGetPersistentHeaders();
|
||||
res.setTrack(req.getTrack());
|
||||
ChatAvatar avatar = server.getAvatarById(req.getSrcAvatarId());
|
||||
if(avatar == null) {
|
||||
res.setResult(ResponseResult.CHATRESULT_SRCAVATARDOESNTEXIST);
|
||||
cluster.send(res.serialize());
|
||||
return;
|
||||
}
|
||||
List<PersistentMessage> pmList = res.getPmList();
|
||||
pmList.addAll(avatar.getPmList().valueCollection());
|
||||
res.setResult(ResponseResult.CHATRESULT_SUCCESS);
|
||||
cluster.send(res.serialize());
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_FRIENDSTATUS, (cluster, packet) -> {
|
||||
RFriendStatus req = new RFriendStatus();
|
||||
req.deserialize(packet);
|
||||
ResFriendStatus res = new ResFriendStatus();
|
||||
res.setTrack(req.getTrack());
|
||||
ChatAvatar avatar = server.getAvatarById(req.getSrcAvatarId());
|
||||
if(avatar == null) {
|
||||
res.setResult(ResponseResult.CHATRESULT_SRCAVATARDOESNTEXIST);
|
||||
res.setFriendsList(new ArrayList<>());
|
||||
cluster.send(res.serialize());
|
||||
return;
|
||||
}
|
||||
res.setFriendsList(avatar.getFriendsList());
|
||||
res.setResult(ResponseResult.CHATRESULT_SUCCESS);
|
||||
cluster.send(res.serialize());
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_IGNORESTATUS, (cluster, packet) -> {
|
||||
RIgnoreStatus req = new RIgnoreStatus();
|
||||
req.deserialize(packet);
|
||||
ResIgnoreStatus res = new ResIgnoreStatus();
|
||||
res.setTrack(req.getTrack());
|
||||
ChatAvatar avatar = server.getAvatarById(req.getSrcAvatarId());
|
||||
if(avatar == null) {
|
||||
res.setResult(ResponseResult.CHATRESULT_SRCAVATARDOESNTEXIST);
|
||||
res.setIgnoreList(new ArrayList<>());
|
||||
cluster.send(res.serialize());
|
||||
return;
|
||||
}
|
||||
res.setIgnoreList(avatar.getIgnoreList());
|
||||
res.setResult(ResponseResult.CHATRESULT_SUCCESS);
|
||||
cluster.send(res.serialize());
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_ADDFRIEND, (cluster, packet) -> {
|
||||
//System.out.println("recv add friend req");
|
||||
RAddFriend req = new RAddFriend();
|
||||
req.deserialize(packet);
|
||||
server.handleAddFriend(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_REMOVEFRIEND, (cluster, packet) -> {
|
||||
RRemoveFriend req = new RRemoveFriend();
|
||||
req.deserialize(packet);
|
||||
server.handleRemoveFriend(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_ADDIGNORE, (cluster, packet) -> {
|
||||
RAddIgnore req = new RAddIgnore();
|
||||
req.deserialize(packet);
|
||||
server.handleAddIgnore(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_REMOVEIGNORE, (cluster, packet) -> {
|
||||
RRemoveIgnore req = new RRemoveIgnore();
|
||||
req.deserialize(packet);
|
||||
server.handleRemoveIgnore(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_GETROOMSUMMARIES, (cluster, packet) -> {
|
||||
RGetRoomSummaries req = new RGetRoomSummaries();
|
||||
//System.out.println("got req RGetRoomSummaries");
|
||||
req.deserialize(packet);
|
||||
server.handleGetRoomSummaries(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_CREATEROOM, (cluster, packet) -> {
|
||||
//System.out.println("got req for create room");
|
||||
RCreateRoom req = new RCreateRoom();
|
||||
req.deserialize(packet);
|
||||
server.handleCreateRoom(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_DESTROYROOM, (cluster, packet) -> {
|
||||
//System.out.println("got del room req");
|
||||
RDestroyRoom req = new RDestroyRoom();
|
||||
req.deserialize(packet);
|
||||
server.handleDestroyRoom(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_GETROOM, (cluster, packet) -> {
|
||||
//System.out.println("got get room req");
|
||||
RGetRoom req = new RGetRoom();
|
||||
req.deserialize(packet);
|
||||
server.handleGetRoom(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_ENTERROOM, (cluster, packet) -> {
|
||||
//System.out.println("got enter room req");
|
||||
REnterRoom req = new REnterRoom();
|
||||
req.deserialize(packet);
|
||||
server.handleEnterRoom(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_FAILOVER_RECREATEROOM, (cluster, packet) -> {
|
||||
RFailoverRecreateRoom req = new RFailoverRecreateRoom();
|
||||
//System.out.println("got request Failover RecreateRoom");
|
||||
req.deserialize(packet);
|
||||
server.handleFailoverRecreateRoom(cluster, req);
|
||||
});
|
||||
|
||||
packetTypes.put(GenericRequest.REQUEST_FAILOVER_RELOGINAVATAR, (cluster, packet) -> {
|
||||
RFailoverReloginAvatar req = new RFailoverReloginAvatar();
|
||||
//System.out.println("got request FailoverReloginAvatar");
|
||||
req.deserialize(packet);
|
||||
if(cluster.getAddress() == null) // store the clusters address at first login since api client doesnt send us any address information otherwise
|
||||
cluster.setAddress(req.getAddress());
|
||||
//System.out.println(req.getAddress().getString() + "+" + req.getName().getString());
|
||||
//System.out.println(req.getLoginLocation().getString());
|
||||
//System.out.println("Attributes: " + req.getLoginAttributes());
|
||||
server.handleFailoverReloginAvatar(cluster, req);
|
||||
});
|
||||
|
||||
packetTypes.put(GenericRequest.REQUEST_LEAVEROOM, (cluster, packet) -> {
|
||||
RLeaveRoom req = new RLeaveRoom();
|
||||
req.deserialize(packet);
|
||||
//System.out.println("Got request leaveRoom: ");
|
||||
server.handleLeaveRoom(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_SENDROOMMESSAGE, (cluster, packet) -> {
|
||||
//System.out.println("got room msg");
|
||||
RSendRoomMessage req = new RSendRoomMessage();
|
||||
req.deserialize(packet);
|
||||
server.handleSendRoomMessage(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_ADDMODERATOR, (cluster, packet) -> {
|
||||
RAddModerator req = new RAddModerator();
|
||||
req.deserialize(packet);
|
||||
server.handleAddModerator(cluster, req);
|
||||
});
|
||||
packetTypes.put(GenericRequest.REQUEST_REMOVEMODERATOR, (cluster, packet) -> {
|
||||
RRemoveModerator req = new RRemoveModerator();
|
||||
req.deserialize(packet);
|
||||
server.handleRemoveModerator(cluster, req);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
ChatApiClient cluster = server.getClusterByChannel(ctx.channel());
|
||||
// msg comes in as an unpooled unsafe buffer in native memory
|
||||
ByteBuf unsafe = (ByteBuf) msg;
|
||||
ByteBuffer packet = ByteBuffer.allocate(((ByteBuf) msg).readableBytes()).order(ByteOrder.LITTLE_ENDIAN);
|
||||
unsafe.getBytes(0, packet);
|
||||
packet.position(0);unsafe.release();
|
||||
if(packet.capacity() < 10) {
|
||||
logger.warn("Recieved packet of size < 6 bytes");
|
||||
ctx.writeAndFlush(unsafe);
|
||||
return;
|
||||
}
|
||||
if(cluster == null) {
|
||||
logger.warn("ChatApiClient object not found for given channel");
|
||||
return;
|
||||
}
|
||||
packet.getInt(); //length of packet in big endian
|
||||
short type = packet.getShort(4);
|
||||
PacketHandler handler = packetTypes.get(type);
|
||||
if(handler == null) {
|
||||
logger.info("Unhandled packet type: {}", type);
|
||||
System.out.println(type);
|
||||
return;
|
||||
}
|
||||
// we are in the IO thread and the submit the handler function to the packet processor to avoid stalling IO operations
|
||||
server.getPacketProcessor().execute(() -> {
|
||||
handler.handle(cluster, packet);
|
||||
});
|
||||
}
|
||||
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
|
||||
public static String bytesToHex(byte[] bytes) {
|
||||
char[] hexChars = new char[bytes.length * 2];
|
||||
for ( int j = 0; j < bytes.length; j++ ) {
|
||||
int v = bytes[j] & 0xFF;
|
||||
hexChars[j * 2] = hexArray[v >>> 4];
|
||||
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
|
||||
}
|
||||
return new String(hexChars);
|
||||
}
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
cause.printStackTrace();
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
server.removeCluster(ctx.channel());
|
||||
}
|
||||
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
server.addCluster(ctx.channel());
|
||||
}
|
||||
|
||||
}
|
||||
58
src/main/java/chat/ChatApiTcpListener.java
Normal file
58
src/main/java/chat/ChatApiTcpListener.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package chat;
|
||||
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.PooledByteBufAllocator;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ChatApiTcpListener {
|
||||
|
||||
private final int port;
|
||||
private Thread recvThread;
|
||||
private ServerBootstrap bootstrap;
|
||||
private static Logger logger = LogManager.getLogger(ChatApiTcpListener.class);
|
||||
|
||||
public ChatApiTcpListener(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
recvThread = new Thread(() -> {
|
||||
EventLoopGroup group = new NioEventLoopGroup();
|
||||
try {
|
||||
bootstrap = new ServerBootstrap();
|
||||
bootstrap.group(group)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.option(ChannelOption.SO_KEEPALIVE, true)
|
||||
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
|
||||
.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
ch.pipeline().addLast("decoder", new LengthFieldBasedFrameDecoder(1000000, 0, 4, -4, 0));
|
||||
ch.pipeline().addLast(new ChatApiTcpHandler());
|
||||
}
|
||||
});
|
||||
logger.info("TCP Server starting on port {}", port);
|
||||
bootstrap.bind(port).sync().channel().closeFuture().await();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
group.shutdownGracefully();
|
||||
}
|
||||
});
|
||||
recvThread.start();
|
||||
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
}
|
||||
290
src/main/java/chat/ChatAvatar.java
Normal file
290
src/main/java/chat/ChatAvatar.java
Normal file
@@ -0,0 +1,290 @@
|
||||
package chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
import gnu.trove.map.TIntObjectMap;
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class ChatAvatar {
|
||||
|
||||
public static final int AVATARATTR_INVISIBLE = 1 << 0;
|
||||
public static final int AVATARATTR_GM = 1 << 1;
|
||||
public static final int AVATARATTR_SUPERGM = 1 << 2;
|
||||
public static final int AVATARATTR_SUPERSNOOP = 1 << 3;
|
||||
public static final int AVATARATTR_EXTENDED = 1 << 4;
|
||||
|
||||
private ChatUnicodeString name;
|
||||
private ChatUnicodeString address;
|
||||
private ChatUnicodeString server = new ChatUnicodeString(); // can just be empty dont need
|
||||
private ChatUnicodeString gateway = new ChatUnicodeString(); // can just be empty dont need
|
||||
private ChatUnicodeString loginLocation;
|
||||
private int avatarId;
|
||||
private int userId; // station ID
|
||||
private int serverId;
|
||||
private int gatewayId;
|
||||
private int attributes;
|
||||
private transient boolean isLoggedIn = false;
|
||||
private transient ChatApiClient cluster;
|
||||
private TIntArrayList mailIds = new TIntArrayList();
|
||||
private transient TIntObjectMap<PersistentMessage> pmList = new TIntObjectHashMap<>();
|
||||
private List<ChatFriend> friendsList = new ArrayList<>();
|
||||
private List<ChatIgnore> ignoreList = new ArrayList<>();
|
||||
|
||||
public ChatUnicodeString getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(ChatUnicodeString name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(ChatUnicodeString address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public void setServer(ChatUnicodeString server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
public void setGateway(ChatUnicodeString gateway) {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getLoginLocation() {
|
||||
return loginLocation;
|
||||
}
|
||||
|
||||
public void setLoginLocation(ChatUnicodeString loginLocation) {
|
||||
this.loginLocation = loginLocation;
|
||||
}
|
||||
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
|
||||
public void setAvatarId(int avatarId) {
|
||||
this.avatarId = avatarId;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
//System.out.println("userId " + userId);
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getServerId() {
|
||||
return serverId;
|
||||
}
|
||||
|
||||
public void setServerId(int serverId) {
|
||||
this.serverId = serverId;
|
||||
}
|
||||
|
||||
public int getGatewayId() {
|
||||
return gatewayId;
|
||||
}
|
||||
|
||||
public void setGatewayId(int gatewayId) {
|
||||
this.gatewayId = gatewayId;
|
||||
}
|
||||
|
||||
public int getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public void setAttributes(int attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
public boolean isLoggedIn() {
|
||||
return isLoggedIn;
|
||||
}
|
||||
|
||||
public void setLoggedIn(boolean isLoggedIn) {
|
||||
this.isLoggedIn = isLoggedIn;
|
||||
}
|
||||
|
||||
public ChatApiClient getCluster() {
|
||||
return cluster;
|
||||
}
|
||||
|
||||
public void setCluster(ChatApiClient cluster) {
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
public TIntArrayList getMailIds() {
|
||||
return mailIds;
|
||||
}
|
||||
|
||||
public void setMailIds(TIntArrayList mailIds) {
|
||||
this.mailIds = mailIds;
|
||||
}
|
||||
|
||||
public byte[] serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(40 + name.getStringLength() * 2 + address.getStringLength() * 2 + loginLocation.getStringLength() * 2 + server.getStringLength() * 2 + gateway.getStringLength() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(avatarId);
|
||||
buf.putInt(userId);
|
||||
buf.put(name.serialize());
|
||||
buf.put(address.serialize());
|
||||
buf.put(gateway.serialize());
|
||||
buf.put(server.serialize());
|
||||
buf.putInt(gatewayId);
|
||||
buf.putInt(serverId);
|
||||
buf.put(loginLocation.serialize());
|
||||
buf.putInt(attributes);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return buf.array();
|
||||
}
|
||||
|
||||
public String getAddressAndName() {
|
||||
return address.getString() + "+" + name.getString();
|
||||
}
|
||||
|
||||
public boolean isInvisible() {
|
||||
return (getAttributes() & AVATARATTR_INVISIBLE) == 1;
|
||||
}
|
||||
|
||||
public boolean isGm() {
|
||||
return (getAttributes() & AVATARATTR_GM) == 1;
|
||||
}
|
||||
|
||||
public boolean isSuperGm() {
|
||||
return (getAttributes() & AVATARATTR_SUPERGM) == 1;
|
||||
}
|
||||
|
||||
public boolean isSuperSnoop() {
|
||||
return (getAttributes() & AVATARATTR_SUPERSNOOP) == 1;
|
||||
}
|
||||
|
||||
public void addMail(PersistentMessage pm) {
|
||||
mailIds.add(pm.getMessageId());
|
||||
pmList.put(pm.getMessageId(), pm);
|
||||
System.out.println("addMail destAva mailIds " + mailIds);
|
||||
System.out.println("adddMail destAva pmList " + pmList);
|
||||
}
|
||||
|
||||
public TIntObjectMap<PersistentMessage> getPmList() {
|
||||
return pmList;
|
||||
}
|
||||
|
||||
public void setPmList(TIntObjectMap<PersistentMessage> pmList) {
|
||||
this.pmList = pmList;
|
||||
}
|
||||
|
||||
public PersistentMessage getPm(int messageId) {
|
||||
return pmList.get(messageId);
|
||||
}
|
||||
|
||||
public void removeMail(PersistentMessage pm) {
|
||||
pmList.remove(pm.getMessageId());
|
||||
mailIds.remove(pm.getMessageId());
|
||||
}
|
||||
|
||||
public List<ChatFriend> getFriendsList() {
|
||||
return friendsList;
|
||||
}
|
||||
|
||||
public void setFriendsList(List<ChatFriend> friendsList) {
|
||||
this.friendsList = friendsList;
|
||||
}
|
||||
|
||||
public List<ChatIgnore> getIgnoreList() {
|
||||
return ignoreList;
|
||||
}
|
||||
|
||||
public void setIgnoreList(List<ChatIgnore> ignoreList) {
|
||||
this.ignoreList = ignoreList;
|
||||
}
|
||||
|
||||
public void addFriend(ChatFriend friend) {
|
||||
friendsList.add(friend);
|
||||
}
|
||||
|
||||
public void addIgnore(ChatIgnore ignore) {
|
||||
ignoreList.add(ignore);
|
||||
}
|
||||
|
||||
public boolean hasFriend(ChatUnicodeString destAddress, ChatUnicodeString destName) {
|
||||
for(ChatFriend friend : friendsList) {
|
||||
if(friend.getAddress().equals(destAddress) && friend.getName().equals(destName))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeFriend(ChatUnicodeString destAddress, ChatUnicodeString destName) {
|
||||
Iterator<ChatFriend> it = friendsList.iterator();
|
||||
while(it.hasNext()) {
|
||||
ChatFriend friend = it.next();
|
||||
if(friend.getAddress().equals(destAddress) && friend.getName().equals(destName))
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasFriend(int avatarId) {
|
||||
for(ChatFriend friend : friendsList) {
|
||||
if(friend.getAvatarId() == avatarId)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ChatFriend getFriend(int avatarId) {
|
||||
for(ChatFriend friend : friendsList) {
|
||||
if(friend.getAvatarId() == avatarId)
|
||||
return friend;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasIgnore(ChatUnicodeString destAddress, ChatUnicodeString destName) {
|
||||
for(ChatIgnore ignore : ignoreList) {
|
||||
if(ignore.getAddress().equals(destAddress) && ignore.getName().equals(destName))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeIgnore(ChatUnicodeString destAddress, ChatUnicodeString destName) {
|
||||
Iterator<ChatIgnore> it = ignoreList.iterator();
|
||||
while(it.hasNext()) {
|
||||
ChatIgnore ignore = it.next();
|
||||
if(ignore.getAddress().equals(destAddress) && ignore.getName().equals(destName))
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasIgnore(int avatarId) {
|
||||
for(ChatIgnore ignore : ignoreList) {
|
||||
if(ignore.getAvatarId() == avatarId)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
69
src/main/java/chat/ChatFriend.java
Normal file
69
src/main/java/chat/ChatFriend.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class ChatFriend {
|
||||
|
||||
private int avatarId;
|
||||
private ChatUnicodeString name;
|
||||
private ChatUnicodeString address;
|
||||
private ChatUnicodeString comment;
|
||||
private short status;
|
||||
|
||||
public byte[] serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(14 + name.getStringLength() * 2 + address.getStringLength() * 2 + comment.getStringLength() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.put(name.serialize());
|
||||
buf.put(address.serialize());
|
||||
buf.put(comment.serialize());
|
||||
buf.putShort(status);
|
||||
return buf.array();
|
||||
}
|
||||
|
||||
public ChatUnicodeString getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(ChatUnicodeString comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
|
||||
public void setAvatarId(int avatarId) {
|
||||
this.avatarId = avatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(ChatUnicodeString name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(ChatUnicodeString address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getFullAddress() {
|
||||
return address.getString() + "+" + name.getString();
|
||||
}
|
||||
|
||||
}
|
||||
45
src/main/java/chat/ChatIgnore.java
Normal file
45
src/main/java/chat/ChatIgnore.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class ChatIgnore {
|
||||
|
||||
private int avatarId;
|
||||
private ChatUnicodeString name;
|
||||
private ChatUnicodeString address;
|
||||
|
||||
public byte[] serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(8 + name.getStringLength() * 2 + address.getStringLength() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.put(name.serialize());
|
||||
buf.put(address.serialize());
|
||||
return buf.array();
|
||||
}
|
||||
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
|
||||
public void setAvatarId(int avatarId) {
|
||||
this.avatarId = avatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(ChatUnicodeString name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(ChatUnicodeString address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
}
|
||||
376
src/main/java/chat/ChatRoom.java
Normal file
376
src/main/java/chat/ChatRoom.java
Normal file
@@ -0,0 +1,376 @@
|
||||
package chat;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import chat.protocol.GenericMessage;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class ChatRoom {
|
||||
|
||||
public static final int ROOMATTR_PRIVATE = 1 << 0;
|
||||
public static final int ROOMATTR_MODERATED = 1 << 1;
|
||||
public static final int ROOMATTR_PERSISTENT = 1 << 2;
|
||||
public static final int ROOMATTR_LOCAL_WORLD = 1 << 4;
|
||||
public static final int ROOMATTR_LOCAL_GAME = 1 << 5;
|
||||
|
||||
private ChatUnicodeString creatorName;
|
||||
private ChatUnicodeString creatorAddress;
|
||||
private int creatorId;
|
||||
private ChatUnicodeString roomName;
|
||||
private ChatUnicodeString roomTopic;
|
||||
private ChatUnicodeString roomPrefix = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomAddress;
|
||||
private ChatUnicodeString roomPassword;
|
||||
private int roomAttributes;
|
||||
private int maxRoomSize = Integer.MAX_VALUE;
|
||||
private int roomId;
|
||||
private int createTime;
|
||||
private int nodeLevel;
|
||||
/*private TIntList avatarList = new TIntArrayList();
|
||||
private TIntList adminList = new TIntArrayList();
|
||||
private TIntList moderatorList = new TIntArrayList();
|
||||
private TIntList tmpModList = new TIntArrayList();
|
||||
private TIntList banList = new TIntArrayList();
|
||||
private TIntList inviteList = new TIntArrayList();
|
||||
private TIntList voiceList = new TIntArrayList();*/
|
||||
|
||||
private List<ChatAvatar> avatarList = new ArrayList<>();
|
||||
private List<ChatAvatar> adminList = new ArrayList<>();
|
||||
private List<ChatAvatar> moderatorList = new ArrayList<>();
|
||||
private List<ChatAvatar> tmpModList = new ArrayList<>();
|
||||
private List<ChatAvatar> banList = new ArrayList<>();
|
||||
private List<ChatAvatar> inviteList = new ArrayList<>();
|
||||
private List<ChatAvatar> voiceList = new ArrayList<>();
|
||||
|
||||
|
||||
public ChatUnicodeString getCreatorName() {
|
||||
return creatorName;
|
||||
}
|
||||
|
||||
public void setCreatorName(ChatUnicodeString creatorName) {
|
||||
this.creatorName = creatorName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getCreatorAddress() {
|
||||
return creatorAddress;
|
||||
}
|
||||
|
||||
public void setCreatorAddress(ChatUnicodeString creatorAddress) {
|
||||
this.creatorAddress = creatorAddress;
|
||||
}
|
||||
|
||||
public int getCreatorId() {
|
||||
return creatorId;
|
||||
}
|
||||
|
||||
public void setCreatorId(int creatorId) {
|
||||
this.creatorId = creatorId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomName() {
|
||||
return roomName;
|
||||
}
|
||||
|
||||
public void setRoomName(ChatUnicodeString roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomTopic() {
|
||||
return roomTopic;
|
||||
}
|
||||
|
||||
public void setRoomTopic(ChatUnicodeString roomTopic) {
|
||||
this.roomTopic = roomTopic;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomPrefix() {
|
||||
return roomPrefix;
|
||||
}
|
||||
|
||||
public void setRoomPrefix(ChatUnicodeString roomPrefix) {
|
||||
this.roomPrefix = roomPrefix;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomAddress() {
|
||||
return roomAddress;
|
||||
}
|
||||
|
||||
public void setRoomAddress(ChatUnicodeString roomAddress) {
|
||||
this.roomAddress = roomAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomPassword() {
|
||||
return roomPassword;
|
||||
}
|
||||
|
||||
public void setRoomPassword(ChatUnicodeString roomPassword) {
|
||||
this.roomPassword = roomPassword;
|
||||
}
|
||||
|
||||
public int getRoomAttributes() {
|
||||
return roomAttributes;
|
||||
}
|
||||
|
||||
public void setRoomAttributes(int roomAttributes) {
|
||||
this.roomAttributes = roomAttributes;
|
||||
}
|
||||
|
||||
public int getMaxRoomSize() {
|
||||
return maxRoomSize;
|
||||
}
|
||||
|
||||
public void setMaxRoomSize(int maxRoomSize) {
|
||||
this.maxRoomSize = maxRoomSize;
|
||||
}
|
||||
|
||||
public int getRoomId() {
|
||||
return roomId;
|
||||
}
|
||||
|
||||
public void setRoomId(int roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
public int getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(int createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public int getNodeLevel() {
|
||||
return nodeLevel;
|
||||
}
|
||||
|
||||
public void setNodeLevel(int nodeLevel) {
|
||||
this.nodeLevel = nodeLevel;
|
||||
}
|
||||
|
||||
public List<ChatAvatar> getAvatarList() {
|
||||
return avatarList;
|
||||
}
|
||||
|
||||
public void setAvatarList(List<ChatAvatar> avatarList) {
|
||||
this.avatarList = avatarList;
|
||||
}
|
||||
|
||||
public List<ChatAvatar> getAdminList() {
|
||||
return adminList;
|
||||
}
|
||||
|
||||
public void setAdminList(List<ChatAvatar> adminList) {
|
||||
this.adminList = adminList;
|
||||
}
|
||||
|
||||
public List<ChatAvatar> getModeratorList() {
|
||||
return moderatorList;
|
||||
}
|
||||
|
||||
public void setModeratorList(List<ChatAvatar> moderatorList) {
|
||||
this.moderatorList = moderatorList;
|
||||
}
|
||||
|
||||
public List<ChatAvatar> getTmpModList() {
|
||||
return tmpModList;
|
||||
}
|
||||
|
||||
public void setTmpModList(List<ChatAvatar> tmpModList) {
|
||||
this.tmpModList = tmpModList;
|
||||
}
|
||||
|
||||
public List<ChatAvatar> getBanList() {
|
||||
return banList;
|
||||
}
|
||||
|
||||
public void setBanList(List<ChatAvatar> banList) {
|
||||
this.banList = banList;
|
||||
}
|
||||
|
||||
public List<ChatAvatar> getInviteList() {
|
||||
return inviteList;
|
||||
}
|
||||
|
||||
public void setInviteList(List<ChatAvatar> inviteList) {
|
||||
this.inviteList = inviteList;
|
||||
}
|
||||
|
||||
public List<ChatAvatar> getVoiceList() {
|
||||
return voiceList;
|
||||
}
|
||||
|
||||
public void setVoiceList(List<ChatAvatar> voiceList) {
|
||||
this.voiceList = voiceList;
|
||||
}
|
||||
|
||||
public boolean isPrivate() {
|
||||
return (getRoomAttributes() & ROOMATTR_PRIVATE) == ROOMATTR_PRIVATE;
|
||||
}
|
||||
|
||||
public boolean isModerated() {
|
||||
return (getRoomAttributes() & ROOMATTR_MODERATED) == ROOMATTR_MODERATED;
|
||||
}
|
||||
|
||||
public boolean isPersistent() {
|
||||
return (getRoomAttributes() & ROOMATTR_PERSISTENT) == ROOMATTR_PERSISTENT;
|
||||
}
|
||||
|
||||
public boolean isLocalWorld() {
|
||||
return (getRoomAttributes() & ROOMATTR_LOCAL_WORLD) == ROOMATTR_LOCAL_WORLD;
|
||||
}
|
||||
|
||||
public boolean isLocalGame() {
|
||||
return (getRoomAttributes() & ROOMATTR_LOCAL_GAME) == ROOMATTR_LOCAL_GAME;
|
||||
}
|
||||
|
||||
public byte[] serialize() {
|
||||
ByteBuf buf = GenericMessage.alloc.buffer().order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.writeBytes(creatorName.serialize());
|
||||
buf.writeBytes(creatorAddress.serialize());
|
||||
buf.writeInt(creatorId);
|
||||
buf.writeBytes(roomName.serialize());
|
||||
buf.writeBytes(roomTopic.serialize());
|
||||
buf.writeBytes(roomPrefix.serialize());
|
||||
buf.writeBytes(roomAddress.serialize());
|
||||
buf.writeBytes(roomPassword.serialize());
|
||||
buf.writeInt(roomAttributes);
|
||||
buf.writeInt(maxRoomSize);
|
||||
buf.writeInt(roomId);
|
||||
buf.writeInt(createTime);
|
||||
buf.writeInt(nodeLevel);
|
||||
buf.writeInt(avatarList.size());
|
||||
for(ChatAvatar avatar : avatarList) {
|
||||
buf.writeBytes(avatar.serialize());
|
||||
}
|
||||
buf.writeInt(adminList.size());
|
||||
for(ChatAvatar admin : adminList) {
|
||||
buf.writeBytes(admin.serialize());
|
||||
}
|
||||
buf.writeInt(moderatorList.size());
|
||||
for(ChatAvatar mod : moderatorList) {
|
||||
buf.writeBytes(mod.serialize());
|
||||
}
|
||||
buf.writeInt(tmpModList.size());
|
||||
for(ChatAvatar mod : tmpModList) {
|
||||
buf.writeBytes(mod.serialize());
|
||||
}
|
||||
buf.writeInt(banList.size());
|
||||
for(ChatAvatar banned : banList) {
|
||||
buf.writeBytes(banned.serialize());
|
||||
}
|
||||
buf.writeInt(inviteList.size());
|
||||
for(ChatAvatar invite : inviteList) {
|
||||
buf.writeBytes(invite.serialize());
|
||||
}
|
||||
buf.writeInt(voiceList.size());
|
||||
for(ChatAvatar voice : voiceList) {
|
||||
buf.writeBytes(voice.serialize());
|
||||
}
|
||||
ByteBuffer packet = ByteBuffer.allocate(buf.writerIndex()).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.getBytes(0, packet);buf.release();
|
||||
return packet.array();
|
||||
}
|
||||
|
||||
public byte[] serializeSummary() {
|
||||
ByteBuf buf = GenericMessage.alloc.buffer().order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.writeBytes(roomAddress.serialize());
|
||||
buf.writeBytes(roomTopic.serialize());
|
||||
buf.writeInt(roomAttributes);
|
||||
buf.writeInt(avatarList.size());
|
||||
buf.writeInt(maxRoomSize);
|
||||
ByteBuffer packet = ByteBuffer.allocate(buf.writerIndex()).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.getBytes(0, packet);buf.release();
|
||||
return packet.array();
|
||||
}
|
||||
|
||||
public void addAvatar(ChatAvatar avatar) {
|
||||
avatarList.add(avatar);
|
||||
}
|
||||
|
||||
public void addAdmin(ChatAvatar avatar) {
|
||||
adminList.add(avatar);
|
||||
}
|
||||
|
||||
public void removeAvatar(ChatAvatar avatar) {
|
||||
avatarList.remove(avatar);
|
||||
}
|
||||
|
||||
public boolean isOnBanList(ChatAvatar avatar) {
|
||||
return banList.contains(avatar);
|
||||
}
|
||||
|
||||
public boolean hasPassword() {
|
||||
return !roomPassword.getString().equals("");
|
||||
}
|
||||
|
||||
public boolean validatePassword(ChatUnicodeString roomPassword) {
|
||||
return this.roomPassword.equals(roomPassword);
|
||||
}
|
||||
|
||||
public boolean isInRoom(ChatAvatar avatar) {
|
||||
return avatarList.contains(avatar);
|
||||
}
|
||||
|
||||
public boolean isAdmin(ChatAvatar avatar) {
|
||||
return adminList.contains(avatar);
|
||||
}
|
||||
|
||||
public boolean isOwner(ChatAvatar avatar) {
|
||||
return creatorId == avatar.getAvatarId();
|
||||
}
|
||||
|
||||
public void addModerator(ChatAvatar destAvatar) {
|
||||
moderatorList.add(destAvatar);
|
||||
}
|
||||
|
||||
public boolean isModerator(ChatAvatar destAvatar) {
|
||||
return moderatorList.contains(destAvatar);
|
||||
}
|
||||
|
||||
public void removeModerator(ChatAvatar destAvatar) {
|
||||
moderatorList.remove(destAvatar);
|
||||
}
|
||||
|
||||
public boolean isBanned(ChatAvatar destAvatar) {
|
||||
return banList.contains(destAvatar);
|
||||
}
|
||||
public boolean isInvited(ChatAvatar destAvatar) {
|
||||
return inviteList.contains(destAvatar);
|
||||
}
|
||||
|
||||
public void addBan(ChatAvatar destAvatar) {
|
||||
banList.add(destAvatar);
|
||||
System.out.println("Banlist " + banList.toString());
|
||||
}
|
||||
public void removeBan(ChatAvatar destAvatar) {
|
||||
banList.remove(destAvatar);
|
||||
System.out.println("Banlist " + banList.toString());
|
||||
}
|
||||
|
||||
public void AddInvite(ChatAvatar destAvatar) {
|
||||
inviteList.add(destAvatar);
|
||||
System.out.println("added to inviteList " + inviteList);
|
||||
}
|
||||
public void RemoveInvite(ChatAvatar destAvatar) {
|
||||
inviteList.remove(destAvatar);
|
||||
System.out.println("removed from inviteList " + inviteList);
|
||||
}
|
||||
public void kickAvatar(ChatAvatar destAvatar) {
|
||||
avatarList.remove(destAvatar);
|
||||
//System.out.println("avatarList " + avatarList);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void leaveRoom(ChatAvatar srcAvatarId) {
|
||||
avatarList.remove(srcAvatarId);
|
||||
//System.out.println("avatarList " + avatarList);
|
||||
}
|
||||
|
||||
}
|
||||
10
src/main/java/chat/PacketHandler.java
Normal file
10
src/main/java/chat/PacketHandler.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PacketHandler {
|
||||
|
||||
public void handle(ChatApiClient cluster, ByteBuffer packet);
|
||||
|
||||
}
|
||||
148
src/main/java/chat/PersistentMessage.java
Normal file
148
src/main/java/chat/PersistentMessage.java
Normal file
@@ -0,0 +1,148 @@
|
||||
package chat;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class PersistentMessage {
|
||||
|
||||
// Header
|
||||
private int messageId;
|
||||
private int avatarId;
|
||||
private int timestamp;
|
||||
private int status;
|
||||
private ChatUnicodeString senderName;
|
||||
private ChatUnicodeString senderAddress;
|
||||
private ChatUnicodeString subject;
|
||||
private ChatUnicodeString folder; // not used in SWG and optional in API mail packets
|
||||
private ChatUnicodeString category; // not used in SWG and optional in API mail packets
|
||||
// + Body
|
||||
private ChatUnicodeString message;
|
||||
private ChatUnicodeString oob;
|
||||
private int fetchResult;
|
||||
|
||||
public int getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public void setMessageId(int messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
|
||||
public void setAvatarId(int avatarId) {
|
||||
this.avatarId = avatarId;
|
||||
}
|
||||
|
||||
public int getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(int timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSenderName() {
|
||||
return senderName;
|
||||
}
|
||||
|
||||
public void setSenderName(ChatUnicodeString senderName) {
|
||||
this.senderName = senderName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSenderAddress() {
|
||||
return senderAddress;
|
||||
}
|
||||
|
||||
public void setSenderAddress(ChatUnicodeString senderAddress) {
|
||||
this.senderAddress = senderAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(ChatUnicodeString subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getFolder() {
|
||||
return folder;
|
||||
}
|
||||
|
||||
public void setFolder(ChatUnicodeString folder) {
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(ChatUnicodeString category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(ChatUnicodeString message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getOob() {
|
||||
return oob;
|
||||
}
|
||||
|
||||
public void setOob(ChatUnicodeString oob) {
|
||||
this.oob = oob;
|
||||
}
|
||||
|
||||
public int getFetchResult() {
|
||||
return fetchResult;
|
||||
}
|
||||
|
||||
public void setFetchResult(int fetchResult) {
|
||||
this.fetchResult = fetchResult;
|
||||
}
|
||||
|
||||
public byte[] serializeHeader() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(28 + senderName.getStringLength() * 2 + senderAddress.getStringLength() * 2 + subject.getStringLength() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(messageId);
|
||||
buf.putInt(avatarId);
|
||||
buf.put(senderName.serialize());
|
||||
buf.put(senderAddress.serialize());
|
||||
buf.put(subject.serialize());
|
||||
buf.putInt(timestamp);
|
||||
buf.putInt(status);
|
||||
return buf.array();
|
||||
}
|
||||
|
||||
public byte[] serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(36 + senderName.getStringLength() * 2 + senderAddress.getStringLength() * 2 + subject.getStringLength() * 2 + message.getStringLength() * 2 + oob.getStringLength() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(messageId);
|
||||
buf.putInt(avatarId);
|
||||
buf.put(senderName.serialize());
|
||||
buf.put(senderAddress.serialize());
|
||||
buf.put(subject.serialize());
|
||||
buf.putInt(timestamp);
|
||||
buf.putInt(status);
|
||||
buf.put(message.serialize());
|
||||
buf.put(oob.serialize());
|
||||
return buf.array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
80
src/main/java/chat/protocol/GenericMessage.java
Normal file
80
src/main/java/chat/protocol/GenericMessage.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package chat.protocol;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.buffer.PooledByteBufAllocator;
|
||||
|
||||
public abstract class GenericMessage {
|
||||
|
||||
public static final ByteBufAllocator alloc = PooledByteBufAllocator.DEFAULT;
|
||||
|
||||
protected short type;
|
||||
|
||||
public final short getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
protected void writeSize(ByteBuffer buf) {
|
||||
int size = buf.capacity();
|
||||
buf.putInt(0, ((size & 0xff) << 24 | (size & 0xff00) << 8 | (size & 0xff0000) >> 8 | (size >> 24) & 0xff));
|
||||
}
|
||||
|
||||
public abstract ByteBuffer serialize();
|
||||
|
||||
public abstract void deserialize(ByteBuffer buf);
|
||||
|
||||
public static final short MESSAGE_INSTANTMESSAGE = 0;
|
||||
public static final short MESSAGE_ROOMMESSAGE = 1;
|
||||
public static final short MESSAGE_BROADCASTMESSAGE = 2;
|
||||
public static final short MESSAGE_FRIENDLOGIN = 3;
|
||||
public static final short MESSAGE_FRIENDLOGOUT = 4;
|
||||
public static final short MESSAGE_KICKROOM = 5;
|
||||
public static final short MESSAGE_ADDMODERATORROOM = 6;
|
||||
public static final short MESSAGE_REMOVEMODERATORROOM = 7;
|
||||
public static final short MESSAGE_REMOVEMODERATORAVATAR = 8;
|
||||
public static final short MESSAGE_ADDBANROOM = 9;
|
||||
public static final short MESSAGE_REMOVEBANROOM = 10;
|
||||
public static final short MESSAGE_REMOVEBANAVATAR = 11;
|
||||
public static final short MESSAGE_ADDINVITEROOM = 12;
|
||||
public static final short MESSAGE_ADDINVITEAVATAR = 13;
|
||||
public static final short MESSAGE_REMOVEINVITEROOM = 14;
|
||||
public static final short MESSAGE_REMOVEINVITEAVATAR = 15;
|
||||
public static final short MESSAGE_ENTERROOM = 16;
|
||||
public static final short MESSAGE_LEAVEROOM = 17;
|
||||
public static final short MESSAGE_DESTROYROOM = 18;
|
||||
public static final short MESSAGE_SETROOMPARAMS = 19;
|
||||
public static final short MESSAGE_PERSISTENTMESSAGE = 20;
|
||||
public static final short MESSAGE_FORCEDLOGOUT = 21;
|
||||
public static final short MESSAGE_UNREGISTERROOMREADY = 22;
|
||||
public static final short MESSAGE_KICKAVATAR = 23;
|
||||
public static final short MESSAGE_ADDMODERATORAVATAR = 24;
|
||||
public static final short MESSAGE_ADDBANAVATAR = 25;
|
||||
public static final short MESSAGE_ADDADMIN = 26;
|
||||
public static final short MESSAGE_REMOVEADMIN = 27;
|
||||
public static final short MESSAGE_FRIENDCONFIRMREQUEST = 28;
|
||||
public static final short MESSAGE_FRIENDCONFIRMRESPONSE = 29;
|
||||
public static final short MESSAGE_CHANGEROOMOWNER = 30;
|
||||
public static final short MESSAGE_FORCEROOMFAILOVER = 31;
|
||||
public static final short MESSAGE_ADDTEMPORARYMODERATORROOM = 32;
|
||||
public static final short MESSAGE_ADDTEMPORARYMODERATORAVATAR = 33;
|
||||
public static final short MESSAGE_REMOVETEMPORARYMODERATORROOM = 34;
|
||||
public static final short MESSAGE_REMOVETEMPORARYMODERATORAVATAR = 35;
|
||||
public static final short MESSAGE_GRANTVOICEROOM = 36;
|
||||
public static final short MESSAGE_GRANTVOICEAVATAR = 37;
|
||||
public static final short MESSAGE_REVOKEVOICEROOM = 38;
|
||||
public static final short MESSAGE_REVOKEVOICEAVATAR = 39;
|
||||
public static final short MESSAGE_SNOOP = 40;
|
||||
public static final short MESSAGE_UIDLIST = 41;
|
||||
public static final short MESSAGE_REQUESTROOMENTRY = 42;
|
||||
public static final short MESSAGE_DELAYEDROOMENTRY = 43;
|
||||
public static final short MESSAGE_DENIEDROOMENTRY = 44;
|
||||
public static final short MESSAGE_FRIENDSTATUS = 45;
|
||||
public static final short MESSAGE_FRIENDCONFIRMRECIPROCATE_REQUEST = 46;
|
||||
public static final short MESSAGE_FRIENDCONFIRMRECIPROCATE_RESPONSE = 47;
|
||||
public static final short MESSAGE_FILTERMESSAGE = 48;
|
||||
public static final short MESSAGE_FAILOVER_AVATAR_LIST = 49;
|
||||
public static final short MESSAGE_NOTIFY_FRIENDS_LIST_CHANGE = 50;
|
||||
public static final short MESSAGE_NOTIFY_FRIEND_IS_REMOVED = 51;
|
||||
|
||||
|
||||
}
|
||||
102
src/main/java/chat/protocol/GenericRequest.java
Normal file
102
src/main/java/chat/protocol/GenericRequest.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package chat.protocol;
|
||||
|
||||
public abstract class GenericRequest extends GenericMessage {
|
||||
|
||||
protected int track;
|
||||
private long timeout;
|
||||
|
||||
public int getTrack() {
|
||||
return track;
|
||||
}
|
||||
|
||||
public void setTrack(int track) {
|
||||
this.track = track;
|
||||
}
|
||||
|
||||
public long getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(long timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public static final short REQUEST_LOGINAVATAR = 0;
|
||||
public static final short REQUEST_LOGOUTAVATAR = 1;
|
||||
public static final short REQUEST_DESTROYAVATAR = 2;
|
||||
public static final short REQUEST_GETAVATAR = 3;
|
||||
public static final short REQUEST_CREATEROOM = 4;
|
||||
public static final short REQUEST_DESTROYROOM = 5;
|
||||
public static final short REQUEST_SENDINSTANTMESSAGE = 6;
|
||||
public static final short REQUEST_SENDROOMMESSAGE = 7;
|
||||
public static final short REQUEST_SENDBROADCASTMESSAGE = 8;
|
||||
public static final short REQUEST_ADDFRIEND = 9;
|
||||
public static final short REQUEST_REMOVEFRIEND = 10;
|
||||
public static final short REQUEST_FRIENDSTATUS = 11;
|
||||
public static final short REQUEST_ADDIGNORE = 12;
|
||||
public static final short REQUEST_REMOVEIGNORE = 13;
|
||||
public static final short REQUEST_ENTERROOM = 14;
|
||||
public static final short REQUEST_LEAVEROOM = 15;
|
||||
public static final short REQUEST_ADDMODERATOR = 16;
|
||||
public static final short REQUEST_REMOVEMODERATOR = 17;
|
||||
public static final short REQUEST_ADDBAN = 18;
|
||||
public static final short REQUEST_REMOVEBAN = 19;
|
||||
public static final short REQUEST_ADDINVITE = 20;
|
||||
public static final short REQUEST_REMOVEINVITE = 21;
|
||||
public static final short REQUEST_KICKAVATAR = 22;
|
||||
public static final short REQUEST_SETROOMPARAMS = 23;
|
||||
public static final short REQUEST_GETROOM = 24;
|
||||
public static final short REQUEST_GETROOMSUMMARIES = 25;
|
||||
public static final short REQUEST_SENDPERSISTENTMESSAGE = 26;
|
||||
public static final short REQUEST_GETPERSISTENTHEADERS = 27;
|
||||
public static final short REQUEST_GETPERSISTENTMESSAGE = 28;
|
||||
public static final short REQUEST_UPDATEPERSISTENTMESSAGE = 29;
|
||||
public static final short REQUEST_UNREGISTERROOM = 30;
|
||||
public static final short REQUEST_IGNORESTATUS = 31;
|
||||
public static final short REQUEST_FAILOVER_RELOGINAVATAR = 32;
|
||||
public static final short REQUEST_FAILOVER_RECREATEROOM = 33;
|
||||
public static final short REQUEST_CONFIRMFRIEND = 34;
|
||||
public static final short REQUEST_GETAVATARKEYWORDS = 35;
|
||||
public static final short REQUEST_SETAVATARKEYWORDS = 36;
|
||||
public static final short REQUEST_SEARCHAVATARKEYWORDS = 37;
|
||||
public static final short REQUEST_GETFANCLUBHANDLE = 38;
|
||||
public static final short REQUEST_UPDATEPERSISTENTMESSAGES = 39;
|
||||
public static final short REQUEST_FINDAVATARBYUID = 40;
|
||||
public static final short REQUEST_CHANGEROOMOWNER = 41;
|
||||
public static final short REQUEST_SETAPIVERSION = 42;
|
||||
public static final short REQUEST_ADDTEMPORARYMODERATOR = 43;
|
||||
public static final short REQUEST_REMOVETEMPORARYMODERATOR = 44;
|
||||
public static final short REQUEST_GRANTVOICE = 45;
|
||||
public static final short REQUEST_REVOKEVOICE = 46;
|
||||
public static final short REQUEST_SETAVATARATTRIBUTES = 47;
|
||||
public static final short REQUEST_ADDSNOOPAVATAR = 48;
|
||||
public static final short REQUEST_REMOVESNOOPAVATAR = 49;
|
||||
public static final short REQUEST_ADDSNOOPROOM = 50;
|
||||
public static final short REQUEST_REMOVESNOOPROOM = 51;
|
||||
public static final short REQUEST_GETSNOOPLIST = 52;
|
||||
public static final short REQUEST_PARTIALPERSISTENTHEADERS = 53;
|
||||
public static final short REQUEST_COUNTPERSISTENTMESSAGES = 54;
|
||||
public static final short REQUEST_PURGEPERSISTENTMESSAGES = 55;
|
||||
public static final short REQUEST_SETFRIENDCOMMENT = 56;
|
||||
public static final short REQUEST_TRANSFERAVATAR = 57;
|
||||
public static final short REQUEST_CHANGEPERSISTENTFOLDER = 58;
|
||||
public static final short REQUEST_ALLOWROOMENTRY = 59;
|
||||
public static final short REQUEST_SETAVATAREMAIL = 60;
|
||||
public static final short REQUEST_SETAVATARINBOXLIMIT = 61;
|
||||
public static final short REQUEST_SENDMULTIPLEPERSISTENTMESSAGES = 62;
|
||||
public static final short REQUEST_GETMULTIPLEPERSISTENTMESSAGES = 63;
|
||||
public static final short REQUEST_ALTERPERISTENTMESSAGE = 64;
|
||||
public static final short REQUEST_GETANYAVATAR = 65;
|
||||
public static final short REQUEST_TEMPORARYAVATAR = 66;
|
||||
public static final short REQUEST_AVATARLIST = 67;
|
||||
public static final short REQUEST_SETAVATARSTATUSMESSAGE = 68;
|
||||
public static final short REQUEST_CONFIRMFRIEND_RECIPROCATE = 69;
|
||||
public static final short REQUEST_ADDFRIEND_RECIPROCATE = 70;
|
||||
public static final short REQUEST_REMOVEFRIEND_RECIPROCATE = 71;
|
||||
public static final short REQUEST_FILTERMESSAGE = 72;
|
||||
public static final short REQUEST_FILTERMESSAGE_EX = 73;
|
||||
|
||||
public static final short REQUEST_REGISTRAR_GETCHATSERVER = 20001;
|
||||
|
||||
|
||||
}
|
||||
112
src/main/java/chat/protocol/GenericResponse.java
Normal file
112
src/main/java/chat/protocol/GenericResponse.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package chat.protocol;
|
||||
|
||||
import chat.protocol.response.ResponseResult;
|
||||
|
||||
public abstract class GenericResponse extends GenericMessage {
|
||||
|
||||
protected int track;
|
||||
private long timeout;
|
||||
protected ResponseResult result = ResponseResult.CHATRESULT_TIMEOUT;
|
||||
|
||||
public int getTrack() {
|
||||
return track;
|
||||
}
|
||||
|
||||
public void setTrack(int track) {
|
||||
this.track = track;
|
||||
}
|
||||
|
||||
public long getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(long timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public ResponseResult getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(ResponseResult result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public static final short RESPONSE_LOGINAVATAR = 0;
|
||||
public static final short RESPONSE_LOGOUTAVATAR = 1;
|
||||
public static final short RESPONSE_DESTROYAVATAR = 2;
|
||||
public static final short RESPONSE_GETAVATAR = 3;
|
||||
public static final short RESPONSE_CREATEROOM = 4;
|
||||
public static final short RESPONSE_DESTROYROOM = 5;
|
||||
public static final short RESPONSE_SENDINSTANTMESSAGE = 6;
|
||||
public static final short RESPONSE_SENDROOMMESSAGE = 7;
|
||||
public static final short RESPONSE_SENDBROADCASTMESSAGE = 8;
|
||||
public static final short RESPONSE_ADDFRIEND = 9;
|
||||
public static final short RESPONSE_REMOVEFRIEND = 10;
|
||||
public static final short RESPONSE_FRIENDSTATUS = 11;
|
||||
public static final short RESPONSE_ADDIGNORE = 12;
|
||||
public static final short RESPONSE_REMOVEIGNORE = 13;
|
||||
public static final short RESPONSE_ENTERROOM = 14;
|
||||
public static final short RESPONSE_LEAVEROOM = 15;
|
||||
public static final short RESPONSE_ADDMODERATOR = 16;
|
||||
public static final short RESPONSE_REMOVEMODERATOR = 17;
|
||||
public static final short RESPONSE_ADDBAN = 18;
|
||||
public static final short RESPONSE_REMOVEBAN = 19;
|
||||
public static final short RESPONSE_ADDINVITE = 20;
|
||||
public static final short RESPONSE_REMOVEINVITE = 21;
|
||||
public static final short RESPONSE_KICKAVATAR = 22;
|
||||
public static final short RESPONSE_SETROOMPARAMS = 23;
|
||||
public static final short RESPONSE_GETROOM = 24;
|
||||
public static final short RESPONSE_GETROOMSUMMARIES = 25;
|
||||
public static final short RESPONSE_SENDPERSISTENTMESSAGE = 26;
|
||||
public static final short RESPONSE_GETPERSISTENTHEADERS = 27;
|
||||
public static final short RESPONSE_GETPERSISTENTMESSAGE = 28;
|
||||
public static final short RESPONSE_UPDATEPERSISTENTMESSAGE = 29;
|
||||
public static final short RESPONSE_UNREGISTERROOM = 30;
|
||||
public static final short RESPONSE_IGNORESTATUS = 31;
|
||||
public static final short RESPONSE_FAILOVER_RELOGINAVATAR = 32;
|
||||
public static final short RESPONSE_FAILOVER_RECREATEROOM = 33;
|
||||
public static final short RESPONSE_CONFIRMFRIEND = 34;
|
||||
public static final short RESPONSE_GETAVATARKEYWORDS = 35;
|
||||
public static final short RESPONSE_SETAVATARKEYWORDS = 36;
|
||||
public static final short RESPONSE_SEARCHAVATARKEYWORDS = 37;
|
||||
public static final short RESPONSE_GETFANCLUBHANDLE = 38;
|
||||
public static final short RESPONSE_UPDATEPERSISTENTMESSAGES = 39;
|
||||
public static final short RESPONSE_FINDAVATARBYUID = 40;
|
||||
public static final short RESPONSE_CHANGEROOMOWNER = 41;
|
||||
public static final short RESPONSE_SETAPIVERSION = 42;
|
||||
public static final short RESPONSE_ADDTEMPORARYMODERATOR = 43;
|
||||
public static final short RESPONSE_REMOVETEMPORARYMODERATOR = 44;
|
||||
public static final short RESPONSE_GRANTVOICE = 45;
|
||||
public static final short RESPONSE_REVOKEVOICE = 46;
|
||||
public static final short RESPONSE_SETAVATARATTRIBUTES = 47;
|
||||
public static final short RESPONSE_ADDSNOOPAVATAR = 48;
|
||||
public static final short RESPONSE_REMOVESNOOPAVATAR = 49;
|
||||
public static final short RESPONSE_ADDSNOOPROOM = 50;
|
||||
public static final short RESPONSE_REMOVESNOOPROOM = 51;
|
||||
public static final short RESPONSE_GETSNOOPLIST = 52;
|
||||
public static final short RESPONSE_PARTIALPERSISTENTHEADERS = 53;
|
||||
public static final short RESPONSE_COUNTPERSISTENTMESSAGES = 54;
|
||||
public static final short RESPONSE_PURGEPERSISTENTMESSAGES = 55;
|
||||
public static final short RESPONSE_SETFRIENDCOMMENT = 56;
|
||||
public static final short RESPONSE_TRANSFERAVATAR = 57;
|
||||
public static final short RESPONSE_CHANGEPERSISTENTFOLDER = 58;
|
||||
public static final short RESPONSE_ALLOWROOMENTRY = 59;
|
||||
public static final short RESPONSE_SETAVATAREMAIL = 60;
|
||||
public static final short RESPONSE_SETAVATARINBOXLIMIT = 61;
|
||||
public static final short RESPONSE_SENDMULTIPLEPERSISTENTMESSAGES = 62;
|
||||
public static final short RESPONSE_GETMULTIPLEPERSISTENTMESSAGES = 63;
|
||||
public static final short RESPONSE_ALTERPERSISTENTMESSAGE = 64;
|
||||
public static final short RESPONSE_GETANYAVATAR = 65;
|
||||
public static final short RESPONSE_TEMPORARYAVATAR = 66;
|
||||
public static final short RESPONSE_AVATARLIST = 67;
|
||||
public static final short RESPONSE_SETSTATUSMESSAGE = 68;
|
||||
public static final short RESPONSE_CONFIRMFRIEND_RECIPROCATE = 69;
|
||||
public static final short RESPONSE_ADDFRIEND_RECIPROCATE = 70;
|
||||
public static final short RESPONSE_REMOVEFRIEND_RECIPROCATE = 71;
|
||||
public static final short RESPONSE_FILTERMESSAGE = 72;
|
||||
public static final short RESPONSE_FILTERMESSAGE_EX = 73;
|
||||
|
||||
public static final short RESPONSE_REGISTRAR_GETCHATSERVER = 20001;
|
||||
|
||||
}
|
||||
58
src/main/java/chat/protocol/message/MDestroyRoom.java
Normal file
58
src/main/java/chat/protocol/message/MDestroyRoom.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package chat.protocol.message;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.ChatAvatar;
|
||||
import chat.protocol.GenericMessage;
|
||||
|
||||
public class MDestroyRoom extends GenericMessage {
|
||||
|
||||
private ChatAvatar srcAvatar;
|
||||
private int roomId;
|
||||
|
||||
public MDestroyRoom() {
|
||||
type = MESSAGE_DESTROYROOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
byte[] avatarBuf = srcAvatar.serialize();
|
||||
ByteBuffer buf = ByteBuffer.allocate(14 + avatarBuf.length).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(0);
|
||||
buf.put(avatarBuf);
|
||||
buf.putInt(roomId);
|
||||
writeSize(buf);freeNative(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
private void freeNative(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public ChatAvatar getSrcAvatar() {
|
||||
return srcAvatar;
|
||||
}
|
||||
|
||||
public void setSrcAvatar(ChatAvatar srcAvatar) {
|
||||
this.srcAvatar = srcAvatar;
|
||||
}
|
||||
|
||||
public int getRoomId() {
|
||||
return roomId;
|
||||
}
|
||||
|
||||
public void setRoomId(int roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
}
|
||||
104
src/main/java/chat/protocol/message/MEnterRoom.java
Normal file
104
src/main/java/chat/protocol/message/MEnterRoom.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package chat.protocol.message;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.ChatAvatar;
|
||||
import chat.protocol.GenericMessage;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class MEnterRoom extends GenericMessage {
|
||||
|
||||
private ChatAvatar srcAvatar;
|
||||
private ChatAvatar Creator;
|
||||
private int roomId;
|
||||
private int SrcAvatarId;
|
||||
private ChatUnicodeString AvatarName;
|
||||
private ChatUnicodeString AvatarAddress;
|
||||
private ChatUnicodeString RoomAddress;
|
||||
private ChatUnicodeString Gateway;
|
||||
private ChatUnicodeString Server;
|
||||
|
||||
public MEnterRoom() {
|
||||
type = MESSAGE_ENTERROOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
byte[] avatarBuf = srcAvatar.serialize();
|
||||
//byte[] CreatorBuf = Creator.serialize();
|
||||
//ByteBuffer buf = ByteBuffer.allocate(30 + avatarBuf.length + AvatarName.getStringLength() * 2 + AvatarAddress.getStringLength() * 2 + Gateway.getStringLength() * 2 + Server.getStringLength() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
ByteBuffer buf = ByteBuffer.allocate(14 + avatarBuf.length ).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(0);
|
||||
|
||||
//buf.put(CreatorBuf);
|
||||
//buf.putInt(roomId);
|
||||
//buf.putInt(SrcAvatarId);
|
||||
//buf.putInt(0);
|
||||
buf.put(avatarBuf);
|
||||
//buf.put(AvatarAddress.serialize());
|
||||
//buf.put(AvatarName.serialize());
|
||||
//buf.put(Gateway.serialize());
|
||||
//buf.put(Server.serialize());
|
||||
//buf.putInt(0);
|
||||
|
||||
//buf.put(RoomAddress.serialize());
|
||||
buf.putInt(roomId);
|
||||
writeSize(buf);freeNative(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
private void freeNative(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public ChatAvatar getSrcAvatar() {
|
||||
return srcAvatar;
|
||||
}
|
||||
|
||||
public void setSrcAvatar(ChatAvatar srcAvatar) {
|
||||
this.srcAvatar = srcAvatar;
|
||||
}
|
||||
|
||||
public void setCreator(ChatAvatar Creator) {
|
||||
this.Creator = Creator;
|
||||
}
|
||||
|
||||
public int getRoomId() {
|
||||
return roomId;
|
||||
}
|
||||
|
||||
public void setRoomId(int roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int SrcAvatarId) {
|
||||
this.SrcAvatarId = SrcAvatarId;
|
||||
}
|
||||
|
||||
public void setAvatarName(ChatUnicodeString AvatarName) {
|
||||
this.AvatarName = AvatarName;
|
||||
}
|
||||
|
||||
public void setAvatarAddress(ChatUnicodeString AvatarAddress) {
|
||||
this.AvatarAddress = AvatarAddress;
|
||||
}
|
||||
|
||||
public void setGateway(ChatUnicodeString Gateway) {
|
||||
this.Gateway = Gateway;
|
||||
}
|
||||
|
||||
public void setServer(ChatUnicodeString Server) {
|
||||
this.Server = Server;
|
||||
}
|
||||
|
||||
}
|
||||
89
src/main/java/chat/protocol/message/MForcedLogout.java
Normal file
89
src/main/java/chat/protocol/message/MForcedLogout.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package chat.protocol.message;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import chat.ChatAvatar;
|
||||
import chat.ChatRoom;
|
||||
import chat.protocol.GenericMessage;
|
||||
import gnu.trove.list.TIntList;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
public class MForcedLogout extends GenericMessage {
|
||||
|
||||
private int destRoomId;
|
||||
private List<ChatRoom> extraRooms = new ArrayList<ChatRoom>();
|
||||
private int roomId;
|
||||
private boolean gotRoom = true;
|
||||
private TIntList destAvatarIdList = new TIntArrayList();
|
||||
private ChatAvatar avatar;
|
||||
int SrcAvatarId;
|
||||
|
||||
public MForcedLogout() {
|
||||
type = MESSAGE_FORCEDLOGOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(14).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(0);
|
||||
//buf.putInt(destAvatarIdList.size());
|
||||
//for(int avatarId : destAvatarIdList.toArray()) {
|
||||
// buf.putInt(avatarId);
|
||||
//}
|
||||
buf.putInt(SrcAvatarId);
|
||||
writeSize(buf);freeNative(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
private void freeNative(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int SrcAvatarId) {
|
||||
this.SrcAvatarId = SrcAvatarId;
|
||||
}
|
||||
|
||||
public void setGotRoom(boolean b) {
|
||||
this.gotRoom = gotRoom;
|
||||
|
||||
}
|
||||
public boolean isGotRoom() {
|
||||
return gotRoom;
|
||||
}
|
||||
|
||||
public void setRoomId(int roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
public void setDestAvatarIdList(TIntList destAvatarIdList) {
|
||||
this.destAvatarIdList = destAvatarIdList;
|
||||
}
|
||||
|
||||
public ChatAvatar getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(ChatAvatar avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
}
|
||||
74
src/main/java/chat/protocol/message/MFriendLogin.java
Normal file
74
src/main/java/chat/protocol/message/MFriendLogin.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package chat.protocol.message;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.ChatAvatar;
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class MFriendLogin extends GenericRequest {
|
||||
|
||||
private ChatAvatar friendAvatar;
|
||||
private ChatUnicodeString friendAddress;
|
||||
private int destAvatarId;
|
||||
private ChatUnicodeString friendStatus = new ChatUnicodeString();
|
||||
|
||||
public MFriendLogin() {
|
||||
type = MESSAGE_FRIENDLOGIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
byte[] avatarBuf = friendAvatar.serialize();
|
||||
ByteBuffer buf = ByteBuffer.allocate(22 + avatarBuf.length + friendAddress.getStringLength() * 2 + friendStatus.getStringLength() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(0);
|
||||
buf.put(avatarBuf);
|
||||
buf.put(friendAddress.serialize());
|
||||
buf.putInt(destAvatarId);
|
||||
buf.put(friendStatus.serialize());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public ChatAvatar getFriendAvatar() {
|
||||
return friendAvatar;
|
||||
}
|
||||
|
||||
public void setFriendAvatar(ChatAvatar friendAvatar) {
|
||||
this.friendAvatar = friendAvatar;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getFriendAddress() {
|
||||
return friendAddress;
|
||||
}
|
||||
|
||||
public void setFriendAddress(ChatUnicodeString friendAddress) {
|
||||
this.friendAddress = friendAddress;
|
||||
}
|
||||
|
||||
public int getDestAvatarId() {
|
||||
return destAvatarId;
|
||||
}
|
||||
|
||||
public void setDestAvatarId(int destAvatarId) {
|
||||
this.destAvatarId = destAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getFriendStatus() {
|
||||
return friendStatus;
|
||||
}
|
||||
|
||||
public void setFriendStatus(ChatUnicodeString friendStatus) {
|
||||
this.friendStatus = friendStatus;
|
||||
}
|
||||
|
||||
}
|
||||
64
src/main/java/chat/protocol/message/MFriendLogout.java
Normal file
64
src/main/java/chat/protocol/message/MFriendLogout.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package chat.protocol.message;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.ChatAvatar;
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class MFriendLogout extends GenericRequest {
|
||||
|
||||
private ChatAvatar friendAvatar;
|
||||
private ChatUnicodeString friendAddress;
|
||||
private int destAvatarId;
|
||||
|
||||
public MFriendLogout() {
|
||||
type = MESSAGE_FRIENDLOGOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
byte[] avatarBuf = friendAvatar.serialize();
|
||||
ByteBuffer buf = ByteBuffer.allocate(18 + avatarBuf.length + friendAddress.getStringLength() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(0);
|
||||
buf.put(avatarBuf);
|
||||
buf.put(friendAddress.serialize());
|
||||
buf.putInt(destAvatarId);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public ChatAvatar getFriendAvatar() {
|
||||
return friendAvatar;
|
||||
}
|
||||
|
||||
public void setFriendAvatar(ChatAvatar friendAvatar) {
|
||||
this.friendAvatar = friendAvatar;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getFriendAddress() {
|
||||
return friendAddress;
|
||||
}
|
||||
|
||||
public void setFriendAddress(ChatUnicodeString friendAddress) {
|
||||
this.friendAddress = friendAddress;
|
||||
}
|
||||
|
||||
public int getDestAvatarId() {
|
||||
return destAvatarId;
|
||||
}
|
||||
|
||||
public void setDestAvatarId(int destAvatarId) {
|
||||
this.destAvatarId = destAvatarId;
|
||||
}
|
||||
|
||||
}
|
||||
90
src/main/java/chat/protocol/message/MLeaveRoom.java
Normal file
90
src/main/java/chat/protocol/message/MLeaveRoom.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package chat.protocol.message;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import chat.ChatAvatar;
|
||||
import chat.ChatRoom;
|
||||
import chat.protocol.GenericMessage;
|
||||
import gnu.trove.list.TIntList;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
public class MLeaveRoom extends GenericMessage {
|
||||
|
||||
private int destRoomId;
|
||||
private List<ChatRoom> extraRooms = new ArrayList<ChatRoom>();
|
||||
private int roomId;
|
||||
private boolean gotRoom = true;
|
||||
private TIntList destAvatarIdList = new TIntArrayList();
|
||||
private ChatAvatar avatar;
|
||||
int SrcAvatarId;
|
||||
|
||||
public MLeaveRoom() {
|
||||
type = MESSAGE_LEAVEROOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(0);
|
||||
//buf.putInt(destAvatarIdList.size());
|
||||
//for(int avatarId : destAvatarIdList.toArray()) {
|
||||
// buf.putInt(avatarId);
|
||||
//}
|
||||
buf.putInt(SrcAvatarId);
|
||||
buf.putInt(roomId);
|
||||
writeSize(buf);freeNative(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
private void freeNative(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int SrcAvatarId) {
|
||||
this.SrcAvatarId = SrcAvatarId;
|
||||
}
|
||||
|
||||
public void setGotRoom(boolean b) {
|
||||
this.gotRoom = gotRoom;
|
||||
|
||||
}
|
||||
public boolean isGotRoom() {
|
||||
return gotRoom;
|
||||
}
|
||||
|
||||
public void setRoomId(int roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
public void setDestAvatarIdList(TIntList destAvatarIdList) {
|
||||
this.destAvatarIdList = destAvatarIdList;
|
||||
}
|
||||
|
||||
public ChatAvatar getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(ChatAvatar avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
}
|
||||
43
src/main/java/chat/protocol/message/MPersistentMessage.java
Normal file
43
src/main/java/chat/protocol/message/MPersistentMessage.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package chat.protocol.message;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.PersistentMessage;
|
||||
import chat.protocol.GenericMessage;
|
||||
|
||||
public class MPersistentMessage extends GenericMessage {
|
||||
|
||||
private PersistentMessage pm;
|
||||
|
||||
public MPersistentMessage() {
|
||||
type = MESSAGE_PERSISTENTMESSAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
byte[] pmBuf = pm.serializeHeader();
|
||||
ByteBuffer buf = ByteBuffer.allocate(14 + pmBuf.length).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(0);
|
||||
buf.putInt(pm.getAvatarId());
|
||||
buf.put(pmBuf);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public PersistentMessage getPm() {
|
||||
return pm;
|
||||
}
|
||||
|
||||
public void setPm(PersistentMessage pm) {
|
||||
this.pm = pm;
|
||||
}
|
||||
|
||||
}
|
||||
100
src/main/java/chat/protocol/message/MRoomMessage.java
Normal file
100
src/main/java/chat/protocol/message/MRoomMessage.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package chat.protocol.message;
|
||||
|
||||
import gnu.trove.list.TIntList;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.ChatAvatar;
|
||||
import chat.protocol.GenericMessage;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class MRoomMessage extends GenericMessage {
|
||||
|
||||
private ChatUnicodeString message;
|
||||
private ChatUnicodeString oob;
|
||||
private int roomId;
|
||||
private TIntList destAvatarIdList = new TIntArrayList();
|
||||
private int messageId;
|
||||
private ChatAvatar avatar;
|
||||
|
||||
public MRoomMessage() {
|
||||
type = MESSAGE_ROOMMESSAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
byte[] avatarBuf = avatar.serialize();
|
||||
ByteBuffer buf = ByteBuffer.allocate(30 + avatarBuf.length + message.getStringLength() * 2 + oob.getStringLength() * 2 + destAvatarIdList.size() * 4).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(0);
|
||||
buf.put(avatarBuf);
|
||||
buf.putInt(roomId);
|
||||
buf.putInt(destAvatarIdList.size());
|
||||
for(int avatarId : destAvatarIdList.toArray()) {
|
||||
buf.putInt(avatarId);
|
||||
}
|
||||
buf.put(message.serialize());
|
||||
buf.put(oob.serialize());
|
||||
buf.putInt(messageId);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public ChatUnicodeString getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(ChatUnicodeString message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getOob() {
|
||||
return oob;
|
||||
}
|
||||
|
||||
public void setOob(ChatUnicodeString oob) {
|
||||
this.oob = oob;
|
||||
}
|
||||
|
||||
public int getRoomId() {
|
||||
return roomId;
|
||||
}
|
||||
|
||||
public void setRoomId(int roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
public TIntList getDestAvatarIdList() {
|
||||
return destAvatarIdList;
|
||||
}
|
||||
|
||||
public void setDestAvatarIdList(TIntList destAvatarIdList) {
|
||||
this.destAvatarIdList = destAvatarIdList;
|
||||
}
|
||||
|
||||
public int getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public void setMessageId(int messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public ChatAvatar getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(ChatAvatar avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
}
|
||||
74
src/main/java/chat/protocol/message/MSendInstantMessage.java
Normal file
74
src/main/java/chat/protocol/message/MSendInstantMessage.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package chat.protocol.message;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.ChatAvatar;
|
||||
import chat.protocol.GenericMessage;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class MSendInstantMessage extends GenericMessage {
|
||||
|
||||
private ChatAvatar srcAvatar;
|
||||
private int destAvatarId;
|
||||
private ChatUnicodeString message;
|
||||
private ChatUnicodeString oob;
|
||||
|
||||
public MSendInstantMessage() {
|
||||
type = MESSAGE_INSTANTMESSAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
byte[] avatarBuf = srcAvatar.serialize();
|
||||
ByteBuffer buf = ByteBuffer.allocate(22 + avatarBuf.length + message.getStringLength() * 2 + oob.getStringLength() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(0);
|
||||
buf.put(avatarBuf);
|
||||
buf.putInt(destAvatarId);
|
||||
buf.put(message.serialize());
|
||||
buf.put(oob.serialize());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public ChatAvatar getSrcAvatar() {
|
||||
return srcAvatar;
|
||||
}
|
||||
|
||||
public void setSrcAvatar(ChatAvatar srcAvatar) {
|
||||
this.srcAvatar = srcAvatar;
|
||||
}
|
||||
|
||||
public int getDestAvatarId() {
|
||||
return destAvatarId;
|
||||
}
|
||||
|
||||
public void setDestAvatarId(int destAvatarId) {
|
||||
this.destAvatarId = destAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(ChatUnicodeString message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getOob() {
|
||||
return oob;
|
||||
}
|
||||
|
||||
public void setOob(ChatUnicodeString oob) {
|
||||
this.oob = oob;
|
||||
}
|
||||
|
||||
}
|
||||
74
src/main/java/chat/protocol/request/RAddBan.java
Normal file
74
src/main/java/chat/protocol/request/RAddBan.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RAddBan extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destRoomAddress = new ChatUnicodeString();
|
||||
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
destAvatarName.deserialize(buf);
|
||||
destAvatarAddress.deserialize(buf);
|
||||
destRoomAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarName() {
|
||||
return destAvatarName;
|
||||
}
|
||||
|
||||
public void setDestAvatarName(ChatUnicodeString destAvatarName) {
|
||||
this.destAvatarName = destAvatarName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarAddress() {
|
||||
return destAvatarAddress;
|
||||
}
|
||||
|
||||
public void setDestAvatarAddress(ChatUnicodeString destAvatarAddress) {
|
||||
this.destAvatarAddress = destAvatarAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestRoomAddress() {
|
||||
return destRoomAddress;
|
||||
}
|
||||
|
||||
public void setDestRoomAddress(ChatUnicodeString destRoomAddress) {
|
||||
this.destRoomAddress = destRoomAddress;
|
||||
}
|
||||
|
||||
}
|
||||
82
src/main/java/chat/protocol/request/RAddFriend.java
Normal file
82
src/main/java/chat/protocol/request/RAddFriend.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RAddFriend extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString destName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString comment = new ChatUnicodeString();
|
||||
private boolean confirm;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
destName.deserialize(buf);
|
||||
destAddress.deserialize(buf);
|
||||
comment.deserialize(buf);
|
||||
confirm = buf.get() != 0;
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestName() {
|
||||
return destName;
|
||||
}
|
||||
|
||||
public void setDestName(ChatUnicodeString destName) {
|
||||
this.destName = destName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAddress() {
|
||||
return destAddress;
|
||||
}
|
||||
|
||||
public void setDestAddress(ChatUnicodeString destAddress) {
|
||||
this.destAddress = destAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(ChatUnicodeString comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public boolean isConfirm() {
|
||||
return confirm;
|
||||
}
|
||||
|
||||
public void setConfirm(boolean confirm) {
|
||||
this.confirm = confirm;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
}
|
||||
63
src/main/java/chat/protocol/request/RAddIgnore.java
Normal file
63
src/main/java/chat/protocol/request/RAddIgnore.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RAddIgnore extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString destName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
destName.deserialize(buf);
|
||||
destAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestName() {
|
||||
return destName;
|
||||
}
|
||||
|
||||
public void setDestName(ChatUnicodeString destName) {
|
||||
this.destName = destName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAddress() {
|
||||
return destAddress;
|
||||
}
|
||||
|
||||
public void setDestAddress(ChatUnicodeString destAddress) {
|
||||
this.destAddress = destAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
}
|
||||
73
src/main/java/chat/protocol/request/RAddInvite.java
Normal file
73
src/main/java/chat/protocol/request/RAddInvite.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RAddInvite extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destRoomAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
destAvatarName.deserialize(buf);
|
||||
destAvatarAddress.deserialize(buf);
|
||||
destRoomAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarName() {
|
||||
return destAvatarName;
|
||||
}
|
||||
|
||||
public void setDestAvatarName(ChatUnicodeString destAvatarName) {
|
||||
this.destAvatarName = destAvatarName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarAddress() {
|
||||
return destAvatarAddress;
|
||||
}
|
||||
|
||||
public void setDestAvatarAddress(ChatUnicodeString destAvatarAddress) {
|
||||
this.destAvatarAddress = destAvatarAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestRoomAddress() {
|
||||
return destRoomAddress;
|
||||
}
|
||||
|
||||
public void setDestRoomAddress(ChatUnicodeString destRoomAddress) {
|
||||
this.destRoomAddress = destRoomAddress;
|
||||
}
|
||||
|
||||
}
|
||||
73
src/main/java/chat/protocol/request/RAddModerator.java
Normal file
73
src/main/java/chat/protocol/request/RAddModerator.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RAddModerator extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destRoomAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
destAvatarName.deserialize(buf);
|
||||
destAvatarAddress.deserialize(buf);
|
||||
destRoomAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarName() {
|
||||
return destAvatarName;
|
||||
}
|
||||
|
||||
public void setDestAvatarName(ChatUnicodeString destAvatarName) {
|
||||
this.destAvatarName = destAvatarName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarAddress() {
|
||||
return destAvatarAddress;
|
||||
}
|
||||
|
||||
public void setDestAvatarAddress(ChatUnicodeString destAvatarAddress) {
|
||||
this.destAvatarAddress = destAvatarAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestRoomAddress() {
|
||||
return destRoomAddress;
|
||||
}
|
||||
|
||||
public void setDestRoomAddress(ChatUnicodeString destRoomAddress) {
|
||||
this.destRoomAddress = destRoomAddress;
|
||||
}
|
||||
|
||||
}
|
||||
105
src/main/java/chat/protocol/request/RCreateRoom.java
Normal file
105
src/main/java/chat/protocol/request/RCreateRoom.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RCreateRoom extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomName = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomTopic = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomPassword = new ChatUnicodeString();
|
||||
private int roomAttributes;
|
||||
private int maxRoomSize;
|
||||
private int roomID;
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
roomName.deserialize(buf);
|
||||
roomTopic.deserialize(buf);
|
||||
roomPassword.deserialize(buf);
|
||||
roomAttributes = buf.getInt();
|
||||
maxRoomSize = buf.getInt();
|
||||
roomAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomAddress() {
|
||||
return roomAddress;
|
||||
}
|
||||
|
||||
public void setRoomAddress(ChatUnicodeString roomAddress) {
|
||||
this.roomAddress = roomAddress;
|
||||
}
|
||||
|
||||
public int getRoomAttributes() {
|
||||
return roomAttributes;
|
||||
}
|
||||
|
||||
public void setRoomAttributes(int roomAttributes) {
|
||||
this.roomAttributes = roomAttributes;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomName() {
|
||||
return roomName;
|
||||
}
|
||||
|
||||
public void setRoomName(ChatUnicodeString roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomTopic() {
|
||||
return roomTopic;
|
||||
}
|
||||
|
||||
public void setRoomTopic(ChatUnicodeString roomTopic) {
|
||||
this.roomTopic = roomTopic;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomPassword() {
|
||||
return roomPassword;
|
||||
}
|
||||
|
||||
public void setRoomPassword(ChatUnicodeString roomPassword) {
|
||||
this.roomPassword = roomPassword;
|
||||
}
|
||||
|
||||
public int getMaxRoomSize() {
|
||||
return maxRoomSize;
|
||||
}
|
||||
|
||||
public void setMaxRoomSize(int maxRoomSize) {
|
||||
this.maxRoomSize = maxRoomSize;
|
||||
}
|
||||
|
||||
}
|
||||
44
src/main/java/chat/protocol/request/RDestroyAvatar.java
Normal file
44
src/main/java/chat/protocol/request/RDestroyAvatar.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RDestroyAvatar extends GenericRequest {
|
||||
|
||||
private int avatarId;
|
||||
private ChatUnicodeString address = new ChatUnicodeString();
|
||||
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
|
||||
public void setAvatarId(int avatarId) {
|
||||
this.avatarId = avatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(ChatUnicodeString address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
avatarId = buf.getInt();
|
||||
address.deserialize(buf);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
72
src/main/java/chat/protocol/request/RDestroyRoom.java
Normal file
72
src/main/java/chat/protocol/request/RDestroyRoom.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RDestroyRoom extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private int RoomId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomAddress = new ChatUnicodeString();
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
roomAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18 + roomAddress.getStringLength() * 2 + srcAddress.getStringLength() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
//buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(srcAvatarId);
|
||||
buf.put(roomAddress.serialize());
|
||||
buf.put(srcAddress.serialize());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public void setRoomId(int RoomId) {
|
||||
this.RoomId = RoomId;
|
||||
}
|
||||
|
||||
public void setTrack(int track) {
|
||||
this.track = track;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomAddress() {
|
||||
return roomAddress;
|
||||
}
|
||||
|
||||
public void setRoomAddress(ChatUnicodeString roomAddress) {
|
||||
this.roomAddress = roomAddress;
|
||||
}
|
||||
|
||||
}
|
||||
133
src/main/java/chat/protocol/request/REnterRoom.java
Normal file
133
src/main/java/chat/protocol/request/REnterRoom.java
Normal file
@@ -0,0 +1,133 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class REnterRoom extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomPassword = new ChatUnicodeString();
|
||||
private boolean passiveCreate;
|
||||
private int roomAttributes;
|
||||
private int maxRoomSize;
|
||||
private ChatUnicodeString roomTopic = new ChatUnicodeString();
|
||||
private boolean requestingEntry; // not used for SWG
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(42 + roomAddress.getStringLength() * 2 + roomPassword.getStringLength() * 2 + roomTopic.getStringLength() * 2 + srcAddress.getStringLength() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
//buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(srcAvatarId);
|
||||
buf.put(roomAddress.serialize());
|
||||
buf.put(roomPassword.serialize());
|
||||
buf.putInt(1);
|
||||
//passiveCreate = buf.put() ;
|
||||
//if(passiveCreate) {
|
||||
buf.put(roomTopic.serialize());
|
||||
buf.putInt(roomAttributes);
|
||||
buf.putInt(maxRoomSize);
|
||||
//}
|
||||
buf.putInt(1);
|
||||
//requestingEntry = buf.get() != 0;
|
||||
buf.put(srcAddress.serialize());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
roomAddress.deserialize(buf);
|
||||
roomPassword.deserialize(buf);
|
||||
passiveCreate = buf.get() != 0;
|
||||
if(passiveCreate) {
|
||||
roomTopic.deserialize(buf);
|
||||
roomAttributes = buf.getInt();
|
||||
maxRoomSize = buf.getInt();
|
||||
}
|
||||
requestingEntry = buf.get() != 0;
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomAddress() {
|
||||
return roomAddress;
|
||||
}
|
||||
|
||||
public void setRoomAddress(ChatUnicodeString roomAddress) {
|
||||
this.roomAddress = roomAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomPassword() {
|
||||
return roomPassword;
|
||||
}
|
||||
|
||||
public void setRoomPassword(ChatUnicodeString roomPassword) {
|
||||
this.roomPassword = roomPassword;
|
||||
}
|
||||
|
||||
public int getRoomAttributes() {
|
||||
return roomAttributes;
|
||||
}
|
||||
|
||||
public void setRoomAttributes(int roomAttributes) {
|
||||
this.roomAttributes = roomAttributes;
|
||||
}
|
||||
|
||||
public boolean isPassiveCreate() {
|
||||
return passiveCreate;
|
||||
}
|
||||
|
||||
public void setPassiveCreate(boolean passiveCreate) {
|
||||
this.passiveCreate = passiveCreate;
|
||||
}
|
||||
|
||||
public int getMaxRoomSize() {
|
||||
return maxRoomSize;
|
||||
}
|
||||
|
||||
public void setMaxRoomSize(int maxRoomSize) {
|
||||
this.maxRoomSize = maxRoomSize;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomTopic() {
|
||||
return roomTopic;
|
||||
}
|
||||
|
||||
public void setRoomTopic(ChatUnicodeString roomTopic) {
|
||||
this.roomTopic = roomTopic;
|
||||
}
|
||||
|
||||
public boolean isRequestingEntry() {
|
||||
return requestingEntry;
|
||||
}
|
||||
|
||||
public void setRequestingEntry(boolean requestingEntry) {
|
||||
this.requestingEntry = requestingEntry;
|
||||
}
|
||||
|
||||
}
|
||||
462
src/main/java/chat/protocol/request/RFailoverRecreateRoom.java
Normal file
462
src/main/java/chat/protocol/request/RFailoverRecreateRoom.java
Normal file
@@ -0,0 +1,462 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import chat.ChatAvatar;
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
import gnu.trove.list.TIntList;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
public class RFailoverRecreateRoom extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private int inRoomAvatarId;
|
||||
private int destAvatarId;
|
||||
private int StationId;
|
||||
private int AvaTyp;
|
||||
private int Zahl2;
|
||||
|
||||
private int roomFailID;
|
||||
//private int roomPrefix;
|
||||
private int createTime;
|
||||
private int avatarCount;
|
||||
private int adminCount;
|
||||
private int moderatorCount;
|
||||
private int tempModeratorCount;
|
||||
private int bannedCount;
|
||||
private int inviteCount;
|
||||
private int VoiceCount;
|
||||
private TIntArrayList inRoomAvatarlist = new TIntArrayList();
|
||||
private TIntArrayList inRoomAdminlist = new TIntArrayList();
|
||||
private TIntArrayList inRoomModeratorlist = new TIntArrayList();
|
||||
private TIntArrayList inRoomTempModeratorlist = new TIntArrayList();
|
||||
private TIntArrayList inRoomBanlist = new TIntArrayList();
|
||||
private TIntArrayList inRoomInvitelist = new TIntArrayList();
|
||||
private TIntArrayList inRoomVoicelist = new TIntArrayList();
|
||||
|
||||
private List<ChatAvatar> destAvatarIdList = new ArrayList<>();
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomName = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomTopic = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomPassword = new ChatUnicodeString();
|
||||
private ChatUnicodeString name = new ChatUnicodeString();
|
||||
private ChatUnicodeString Address = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomPrefix = new ChatUnicodeString();
|
||||
private ChatUnicodeString AvaName = new ChatUnicodeString();
|
||||
private ChatUnicodeString AvaAddress = new ChatUnicodeString();
|
||||
|
||||
private ChatUnicodeString AdminAvaName = new ChatUnicodeString();
|
||||
private ChatUnicodeString AdminAvaAddress = new ChatUnicodeString();
|
||||
private int inRoomAdminAvatarId;
|
||||
private int AdminStationId;
|
||||
private int AdminAvaTyp;
|
||||
|
||||
private ChatUnicodeString ModeratorAvaName = new ChatUnicodeString();
|
||||
private ChatUnicodeString ModeratorAvaAddress = new ChatUnicodeString();
|
||||
private int inRoomModeratorAvatarId;
|
||||
private int ModeratorStationId;
|
||||
private int ModeratorAvaTyp;
|
||||
|
||||
private ChatUnicodeString TempModeratorAvaName = new ChatUnicodeString();
|
||||
private ChatUnicodeString TempModeratorAvaAddress = new ChatUnicodeString();
|
||||
private int inRoomTempModeratorAvatarId;
|
||||
private int TempModeratorStationId;
|
||||
private int TempModeratorAvaTyp;
|
||||
|
||||
private ChatUnicodeString BannedAvaName = new ChatUnicodeString();
|
||||
private ChatUnicodeString BannedAvaAddress = new ChatUnicodeString();
|
||||
private int inRoomBannedAvatarId;
|
||||
private int BannedStationId;
|
||||
private int BannedAvaTyp;
|
||||
|
||||
private ChatUnicodeString InviteAvaName = new ChatUnicodeString();
|
||||
private ChatUnicodeString InviteAvaAddress = new ChatUnicodeString();
|
||||
private int inRoomInviteAvatarId;
|
||||
private int InviteStationId;
|
||||
private int InviteAvaTyp;
|
||||
|
||||
private ChatUnicodeString VoiceAvaName = new ChatUnicodeString();
|
||||
private ChatUnicodeString VoiceAvaAddress = new ChatUnicodeString();
|
||||
private int inRoomVoiceAvatarId;
|
||||
private int VoiceStationId;
|
||||
private int VoiceAvaTyp;
|
||||
|
||||
private int roomAttributes;
|
||||
private int maxRoomSize;
|
||||
private ChatUnicodeString serializeWithLocalAvatarsOnly = new ChatUnicodeString();
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
serializeWithLocalAvatarsOnly();
|
||||
name.deserialize(buf);
|
||||
Address.deserialize(buf);
|
||||
srcAvatarId = buf.getInt();
|
||||
roomName.deserialize(buf);
|
||||
roomTopic.deserialize(buf);
|
||||
roomPassword.deserialize(buf);
|
||||
roomPrefix.deserialize(buf);
|
||||
roomAddress.deserialize(buf);
|
||||
roomAttributes = buf.getInt();
|
||||
maxRoomSize = buf.getInt();
|
||||
roomFailID = buf.getInt();//System.out.println("roomFailID " + roomFailID);
|
||||
createTime = buf.getInt();
|
||||
|
||||
|
||||
//adminCount = buf.getInt(); System.out.println("adminCount " + adminCount);
|
||||
//AvatarId = buf.getInt(); System.out.println("AvatarId1 " + AvatarId);
|
||||
//moderatorCount = buf.getInt(); System.out.println("moderatorCount " + moderatorCount);
|
||||
//tempModeratorCount = buf.getInt(); System.out.println("tempModeratorCount " + tempModeratorCount);
|
||||
//bannedCount = buf.getInt(); System.out.println("bannedCount " + bannedCount);
|
||||
//inviteCount = buf.getInt(); System.out.println("inviteCount " + inviteCount);
|
||||
//VoiceCount = buf.getInt(); System.out.println("VoiceCount " + VoiceCount);
|
||||
//System.out.println("hasArraylenght " + buf.array().length);
|
||||
//System.out.println("hasArraygetClass " + buf.array().getClass());
|
||||
//System.out.println("hasArraygetPosition " + buf.position());
|
||||
//System.out.println("hasArraygetCapacity " + buf.capacity());
|
||||
|
||||
|
||||
ArrayList<Byte> AvatarIds = new ArrayList<>();
|
||||
int [] einArray;
|
||||
einArray = new int[buf.remaining()];
|
||||
|
||||
//inRoomAvatars
|
||||
avatarCount = buf.getInt();// System.out.println("avatarCount " + avatarCount);
|
||||
for (int i=0;i < avatarCount ; i++){
|
||||
inRoomAvatarId = buf.getInt();
|
||||
//System.out.println("inRoomAvatarId " + inRoomAvatarId);
|
||||
inRoomAvatarlist.add(inRoomAvatarId);
|
||||
//System.out.println("inRoomAvatarlist " + inRoomAvatarlist);
|
||||
StationId = buf.getInt();
|
||||
//System.out.println("StationId " + StationId);
|
||||
AvaName.deserialize(buf);
|
||||
//System.out.println("AvaName " + AvaName.getString());
|
||||
AvaAddress.deserialize(buf);
|
||||
//System.out.println("AvaAddress " + AvaAddress.getString());
|
||||
AvaTyp = buf.getInt();
|
||||
//System.out.println("AvaTyp " + AvaTyp);
|
||||
Zahl2 = buf.getInt();
|
||||
//System.out.println("Zahl2 " + Zahl2);
|
||||
|
||||
//AvatarIds.add((byte) buf.getChar());
|
||||
//int digits = (int)Math.floor(Math.log10(Math.abs(AvatarId)));
|
||||
//if (digits == 10 || digits == 9 ){
|
||||
//}
|
||||
}
|
||||
//Zahl2 = buf.getInt();
|
||||
//System.out.println("Zahl2 " + Zahl2);
|
||||
|
||||
//inRoomAdmin
|
||||
adminCount = buf.getInt();
|
||||
//System.out.println("adminCount " + adminCount);
|
||||
for (int i=0;i < adminCount ; i++){
|
||||
inRoomAdminAvatarId = buf.getInt();
|
||||
//System.out.println("inRoomAdminAvatarId " + inRoomAdminAvatarId);
|
||||
inRoomAdminlist.add(inRoomAdminAvatarId);
|
||||
//System.out.println("inRoomAdminlist " + inRoomAdminlist);
|
||||
AdminStationId = buf.getInt();
|
||||
//System.out.println("AdminStationId " + AdminStationId);
|
||||
AdminAvaName.deserialize(buf);
|
||||
//System.out.println("AdminAvaName " + AdminAvaName.getString());
|
||||
AdminAvaAddress.deserialize(buf);
|
||||
//System.out.println("AdminAvaAddress " + AdminAvaAddress.getString());
|
||||
AdminAvaTyp = buf.getInt();
|
||||
//System.out.println("AdminAvaTyp " + AdminAvaTyp);
|
||||
Zahl2 = buf.getInt();
|
||||
//System.out.println("Zahl2 " + Zahl2);
|
||||
|
||||
}
|
||||
|
||||
//Zahl2 = buf.getInt();
|
||||
//System.out.println("Zahl2 " + Zahl2);
|
||||
|
||||
//inRoomModerator
|
||||
moderatorCount = buf.getInt();
|
||||
//System.out.println("moderatorCount " + moderatorCount);
|
||||
for (int i=0;i < moderatorCount ; i++){
|
||||
inRoomModeratorAvatarId = buf.getInt();
|
||||
//System.out.println("inRoomModeratorAvatarId " + inRoomModeratorAvatarId);
|
||||
inRoomModeratorlist.add(inRoomModeratorAvatarId);
|
||||
//System.out.println("inRoomModeratorlist " + inRoomModeratorlist);
|
||||
ModeratorStationId = buf.getInt();
|
||||
//System.out.println("ModeratorStationId " + ModeratorStationId);
|
||||
ModeratorAvaName.deserialize(buf);
|
||||
//System.out.println("ModeratorAvaName " + ModeratorAvaName.getString());
|
||||
ModeratorAvaAddress.deserialize(buf);
|
||||
//System.out.println("ModeratorAvaAddress " + ModeratorAvaAddress.getString());
|
||||
ModeratorAvaTyp = buf.getInt();
|
||||
//System.out.println("ModeratorAvaTyp " + ModeratorAvaTyp);
|
||||
Zahl2 = buf.getInt();
|
||||
//System.out.println("Zahl2 " + Zahl2);
|
||||
}
|
||||
|
||||
//inRoomTempModerator
|
||||
tempModeratorCount = buf.getInt();
|
||||
//System.out.println("tempModeratorCount " + tempModeratorCount);
|
||||
for (int i=0;i < tempModeratorCount ; i++){
|
||||
inRoomTempModeratorAvatarId = buf.getInt();
|
||||
//System.out.println("inRoomTempModeratorAvatarId " + inRoomTempModeratorAvatarId);
|
||||
inRoomTempModeratorlist.add(inRoomTempModeratorAvatarId);
|
||||
//System.out.println("inRoomTempModeratorlist " + inRoomTempModeratorlist);
|
||||
TempModeratorStationId = buf.getInt();
|
||||
//System.out.println("TempModeratorStationId " + TempModeratorStationId);
|
||||
TempModeratorAvaName.deserialize(buf);
|
||||
//System.out.println("TempModeratorAvaName " + TempModeratorAvaName.getString());
|
||||
TempModeratorAvaAddress.deserialize(buf);
|
||||
//System.out.println("TempModeratorAvaAddress " + TempModeratorAvaAddress.getString());
|
||||
TempModeratorAvaTyp = buf.getInt();
|
||||
//System.out.println("TempModeratorAvaTyp " + TempModeratorAvaTyp);
|
||||
Zahl2 = buf.getInt();
|
||||
//System.out.println("Zahl2 " + Zahl2);
|
||||
}
|
||||
|
||||
//inRoomBanned
|
||||
bannedCount = buf.getInt();
|
||||
//System.out.println("bannedCount " + bannedCount);
|
||||
for (int i=0;i < bannedCount ; i++){
|
||||
inRoomBannedAvatarId = buf.getInt();
|
||||
//System.out.println("inRoomBannedAvatarId " + inRoomBannedAvatarId);
|
||||
inRoomBanlist.add(inRoomBannedAvatarId);
|
||||
//System.out.println("inRoomBanlist " + inRoomBanlist);
|
||||
BannedStationId = buf.getInt();
|
||||
//System.out.println("BannedStationId " + BannedStationId);
|
||||
BannedAvaName.deserialize(buf);
|
||||
//System.out.println("BannedAvaName " + BannedAvaName.getString());
|
||||
BannedAvaAddress.deserialize(buf);
|
||||
//System.out.println("BannedAvaAddress " + BannedAvaAddress.getString());
|
||||
BannedAvaTyp = buf.getInt();
|
||||
//System.out.println("BannedAvaTyp " + BannedAvaTyp);
|
||||
Zahl2 = buf.getInt();
|
||||
//System.out.println("Zahl2 " + Zahl2);
|
||||
}
|
||||
|
||||
//inRoomInvited
|
||||
inviteCount = buf.getInt();
|
||||
//System.out.println("inviteCount " + inviteCount);
|
||||
for (int i=0;i < inviteCount ; i++){
|
||||
inRoomInviteAvatarId = buf.getInt();
|
||||
//System.out.println("inRoomInviteAvatarId " + inRoomInviteAvatarId);
|
||||
inRoomInvitelist.add(inRoomInviteAvatarId);
|
||||
//System.out.println("inRoomInvitelist " + inRoomInvitelist);
|
||||
InviteStationId = buf.getInt();
|
||||
//System.out.println("InviteStationId " + InviteStationId);
|
||||
InviteAvaName.deserialize(buf);
|
||||
//System.out.println("InviteAvaName " + InviteAvaName.getString());
|
||||
InviteAvaAddress.deserialize(buf);
|
||||
//System.out.println("InviteAvaAddress " + InviteAvaAddress.getString());
|
||||
InviteAvaTyp = buf.getInt();
|
||||
//System.out.println("InviteAvaTyp " + InviteAvaTyp);
|
||||
Zahl2 = buf.getInt();
|
||||
//System.out.println("Zahl2 " + Zahl2);
|
||||
}
|
||||
//inRoomVoice
|
||||
VoiceCount = buf.getInt();
|
||||
//System.out.println("VoiceCount " + VoiceCount);
|
||||
for (int i=0;i < VoiceCount ; i++){
|
||||
inRoomVoiceAvatarId = buf.getInt();
|
||||
//System.out.println("inRoomVoiceAvatarId " + inRoomVoiceAvatarId);
|
||||
inRoomVoicelist.add(inRoomVoiceAvatarId);
|
||||
//System.out.println("inRoomVoicelist " + inRoomVoicelist);
|
||||
VoiceStationId = buf.getInt();
|
||||
//System.out.println("VoiceStationId " + VoiceStationId);
|
||||
VoiceAvaName.deserialize(buf);
|
||||
//System.out.println("VoiceAvaName " + VoiceAvaName.getString());
|
||||
VoiceAvaAddress.deserialize(buf);
|
||||
//System.out.println("VoiceAvaAddress " + VoiceAvaAddress.getString());
|
||||
VoiceAvaTyp = buf.getInt();
|
||||
//System.out.println("VoiceAvaTyp " + VoiceAvaTyp);
|
||||
Zahl2 = buf.getInt();
|
||||
//System.out.println("Zahl2 " + Zahl2);
|
||||
}
|
||||
}
|
||||
|
||||
private void serializeWithLocalAvatarsOnly() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public ChatUnicodeString getcreatorName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAddress() {
|
||||
return Address;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getroomPrefix() {
|
||||
return roomPrefix;
|
||||
}
|
||||
|
||||
public int getroomFailID() {
|
||||
return roomFailID;
|
||||
}
|
||||
public void setRoomPrefix(ChatUnicodeString roomPrefix) {
|
||||
this.roomPrefix = roomPrefix;
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public int getdestAvatarId() {
|
||||
return destAvatarId;
|
||||
}
|
||||
|
||||
public int getavatarCount() {
|
||||
return avatarCount;
|
||||
}
|
||||
|
||||
public TIntArrayList getinRoomAvatarlist() {
|
||||
return inRoomAvatarlist;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAvaAddress() {
|
||||
return AvaAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAvaName() {
|
||||
return AvaName;
|
||||
}
|
||||
|
||||
public int getinRoomAvatarId() {
|
||||
return inRoomAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomAddress() {
|
||||
return roomAddress;
|
||||
}
|
||||
|
||||
public void setRoomAddress(ChatUnicodeString roomAddress) {
|
||||
this.roomAddress = roomAddress;
|
||||
}
|
||||
|
||||
public int getRoomAttributes() {
|
||||
return roomAttributes;
|
||||
}
|
||||
|
||||
public void setRoomAttributes(int roomAttributes) {
|
||||
this.roomAttributes = roomAttributes;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomName() {
|
||||
return roomName;
|
||||
}
|
||||
|
||||
public void setRoomName(ChatUnicodeString roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomTopic() {
|
||||
return roomTopic;
|
||||
}
|
||||
|
||||
public void setRoomTopic(ChatUnicodeString roomTopic) {
|
||||
this.roomTopic = roomTopic;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomPassword() {
|
||||
return roomPassword;
|
||||
}
|
||||
|
||||
public void setRoomPassword(ChatUnicodeString roomPassword) {
|
||||
this.roomPassword = roomPassword;
|
||||
}
|
||||
|
||||
public int getMaxRoomSize() {
|
||||
return maxRoomSize;
|
||||
}
|
||||
|
||||
public void setMaxRoomSize(int maxRoomSize) {
|
||||
this.maxRoomSize = maxRoomSize;
|
||||
}
|
||||
|
||||
public TIntList getDestAvatarIdList() {
|
||||
return (TIntList) destAvatarIdList;
|
||||
}
|
||||
|
||||
//inRoomAdmin
|
||||
public int getAdminCount() {
|
||||
return adminCount;
|
||||
}
|
||||
|
||||
public TIntArrayList getinRoomAdminlist() {
|
||||
return inRoomAdminlist;
|
||||
}
|
||||
|
||||
//inRoomModerator
|
||||
public int getModeratorCount() {
|
||||
return moderatorCount;
|
||||
}
|
||||
|
||||
public TIntArrayList getinRoomModeratorlist() {
|
||||
return inRoomModeratorlist;
|
||||
}
|
||||
|
||||
//inRoomTempModerator
|
||||
public int getTempModeratorCount() {
|
||||
return tempModeratorCount;
|
||||
}
|
||||
|
||||
public TIntArrayList getinRoomTempModeratorlist() {
|
||||
return inRoomTempModeratorlist;
|
||||
}
|
||||
|
||||
//inRoomBan
|
||||
public int getBanCount() {
|
||||
return bannedCount;
|
||||
}
|
||||
|
||||
public TIntArrayList getinRoomBanlist() {
|
||||
return inRoomBanlist;
|
||||
}
|
||||
|
||||
//inRoomInvite
|
||||
public int getInviteCount() {
|
||||
return inviteCount;
|
||||
}
|
||||
|
||||
public TIntArrayList getinRoomInvitelist() {
|
||||
return inRoomInvitelist;
|
||||
}
|
||||
|
||||
//inRoomVoice
|
||||
public int getVoiceCount() {
|
||||
return VoiceCount;
|
||||
}
|
||||
|
||||
public TIntArrayList getinRoomVoicelist() {
|
||||
return inRoomVoicelist;
|
||||
}
|
||||
|
||||
|
||||
//public void setDestAvatarIdList(TIntList destAvatarIdList) {
|
||||
// this.destAvatarIdList = destAvatarIdList;
|
||||
//}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RFailoverReloginAvatar extends GenericRequest {
|
||||
|
||||
private int userId;
|
||||
private int AvatarId;
|
||||
private ChatUnicodeString name = new ChatUnicodeString();
|
||||
private ChatUnicodeString address = new ChatUnicodeString();
|
||||
private ChatUnicodeString loginLocation = new ChatUnicodeString();
|
||||
private int loginPriority;
|
||||
private int loginAttributes;
|
||||
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
setAvatarId(buf.getInt());
|
||||
setUserId(buf.getInt());
|
||||
name.deserialize(buf);
|
||||
address.deserialize(buf);
|
||||
loginLocation.deserialize(buf);
|
||||
setLoginPriority(buf.getInt());
|
||||
setLoginAttributes(buf.getInt());
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getAvatarId() {
|
||||
return AvatarId;
|
||||
}
|
||||
|
||||
public void setAvatarId(int userId) {
|
||||
this.AvatarId = AvatarId;
|
||||
}
|
||||
|
||||
public int getLoginPriority() {
|
||||
return loginPriority;
|
||||
}
|
||||
|
||||
public void setLoginPriority(int loginPriority) {
|
||||
this.loginPriority = loginPriority;
|
||||
}
|
||||
|
||||
public int getLoginAttributes() {
|
||||
return loginAttributes;
|
||||
}
|
||||
|
||||
public void setLoginAttributes(int loginAttributes) {
|
||||
this.loginAttributes = loginAttributes;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(ChatUnicodeString name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(ChatUnicodeString address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getLoginLocation() {
|
||||
return loginLocation;
|
||||
}
|
||||
|
||||
public void setLoginLocation(ChatUnicodeString loginLocation) {
|
||||
this.loginLocation = loginLocation;
|
||||
}
|
||||
|
||||
}
|
||||
43
src/main/java/chat/protocol/request/RFriendStatus.java
Normal file
43
src/main/java/chat/protocol/request/RFriendStatus.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RFriendStatus extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
}
|
||||
42
src/main/java/chat/protocol/request/RGetAnyAvatar.java
Normal file
42
src/main/java/chat/protocol/request/RGetAnyAvatar.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RGetAnyAvatar extends GenericRequest {
|
||||
|
||||
private ChatUnicodeString name = new ChatUnicodeString();
|
||||
private ChatUnicodeString address = new ChatUnicodeString();
|
||||
|
||||
public ChatUnicodeString getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(ChatUnicodeString name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(ChatUnicodeString address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
name.deserialize(buf);
|
||||
address.deserialize(buf);
|
||||
}
|
||||
}
|
||||
44
src/main/java/chat/protocol/request/RGetAvatar.java
Normal file
44
src/main/java/chat/protocol/request/RGetAvatar.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RGetAvatar extends GenericRequest {
|
||||
|
||||
private ChatUnicodeString name = new ChatUnicodeString();
|
||||
private ChatUnicodeString address = new ChatUnicodeString();
|
||||
|
||||
public ChatUnicodeString getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(ChatUnicodeString name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(ChatUnicodeString address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
name.deserialize(buf);
|
||||
address.deserialize(buf);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
|
||||
public class RGetPersistentHeaders extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private int category;
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
category = buf.getInt();
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public int getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(int category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
|
||||
public class RGetPersistentMessage extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private int messageId;
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
messageId = buf.getInt();
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public int getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public void setMessageId(int messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
}
|
||||
57
src/main/java/chat/protocol/request/RGetRoom.java
Normal file
57
src/main/java/chat/protocol/request/RGetRoom.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.ChatApiTcpHandler;
|
||||
import chat.ChatAvatar;
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RGetRoom extends GenericRequest {
|
||||
|
||||
private ChatUnicodeString roomAddress = new ChatUnicodeString();
|
||||
private ChatAvatar avatar;
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(10 + roomAddress.getString().length() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.put(roomAddress.serialize());
|
||||
//buf.putInt(roomId);
|
||||
writeSize(buf);freeNative(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
private void freeNative(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
roomAddress.deserialize(buf);
|
||||
//System.out.println(ChatApiTcpHandler.bytesToHex(buf.array()));
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomAddress() {
|
||||
return roomAddress;
|
||||
}
|
||||
|
||||
public void setRoomAddress(ChatUnicodeString roomAddress) {
|
||||
this.roomAddress = roomAddress;
|
||||
}
|
||||
|
||||
public ChatAvatar getAvatarAddress() {
|
||||
// TODO Auto-generated method stub
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public int setTrack() {
|
||||
return track;
|
||||
}
|
||||
|
||||
}
|
||||
43
src/main/java/chat/protocol/request/RGetRoomSummaries.java
Normal file
43
src/main/java/chat/protocol/request/RGetRoomSummaries.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RGetRoomSummaries extends GenericRequest {
|
||||
|
||||
private ChatUnicodeString startNodeAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomFilter = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
startNodeAddress.deserialize(buf);
|
||||
roomFilter.deserialize(buf);
|
||||
}
|
||||
|
||||
public ChatUnicodeString getStartNodeAddress() {
|
||||
return startNodeAddress;
|
||||
}
|
||||
|
||||
public void setStartNodeAddress(ChatUnicodeString startNodeAddress) {
|
||||
this.startNodeAddress = startNodeAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomFilter() {
|
||||
return roomFilter;
|
||||
}
|
||||
|
||||
public void setRoomFilter(ChatUnicodeString roomFilter) {
|
||||
this.roomFilter = roomFilter;
|
||||
}
|
||||
|
||||
}
|
||||
43
src/main/java/chat/protocol/request/RIgnoreStatus.java
Normal file
43
src/main/java/chat/protocol/request/RIgnoreStatus.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RIgnoreStatus extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
}
|
||||
73
src/main/java/chat/protocol/request/RKickAvatar.java
Normal file
73
src/main/java/chat/protocol/request/RKickAvatar.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RKickAvatar extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destRoomAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
destAvatarName.deserialize(buf);
|
||||
destAvatarAddress.deserialize(buf);
|
||||
destRoomAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarName() {
|
||||
return destAvatarName;
|
||||
}
|
||||
|
||||
public void setDestAvatarName(ChatUnicodeString destAvatarName) {
|
||||
this.destAvatarName = destAvatarName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarAddress() {
|
||||
return destAvatarAddress;
|
||||
}
|
||||
|
||||
public void setDestAvatarAddress(ChatUnicodeString destAvatarAddress) {
|
||||
this.destAvatarAddress = destAvatarAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestRoomAddress() {
|
||||
return destRoomAddress;
|
||||
}
|
||||
|
||||
public void setDestRoomAddress(ChatUnicodeString destRoomAddress) {
|
||||
this.destRoomAddress = destRoomAddress;
|
||||
}
|
||||
|
||||
}
|
||||
53
src/main/java/chat/protocol/request/RLeaveRoom.java
Normal file
53
src/main/java/chat/protocol/request/RLeaveRoom.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RLeaveRoom extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
roomAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomAddress() {
|
||||
return roomAddress;
|
||||
}
|
||||
|
||||
public void setRoomAddress(ChatUnicodeString roomAddress) {
|
||||
this.roomAddress = roomAddress;
|
||||
}
|
||||
|
||||
}
|
||||
82
src/main/java/chat/protocol/request/RLoginAvatar.java
Normal file
82
src/main/java/chat/protocol/request/RLoginAvatar.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RLoginAvatar extends GenericRequest {
|
||||
|
||||
private int userId;
|
||||
private ChatUnicodeString name = new ChatUnicodeString();
|
||||
private ChatUnicodeString address = new ChatUnicodeString();
|
||||
private ChatUnicodeString loginLocation = new ChatUnicodeString();
|
||||
private int loginPriority;
|
||||
private int loginAttributes;
|
||||
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
setUserId(buf.getInt());
|
||||
name.deserialize(buf);
|
||||
address.deserialize(buf);
|
||||
loginLocation.deserialize(buf);//System.out.println("LoginLocation " + loginLocation.getString());
|
||||
setLoginPriority(buf.getInt());//System.out.println("LoginPriority " + loginPriority);
|
||||
setLoginAttributes(buf.getInt());//System.out.println("setLoginAttributes " + loginAttributes);
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getLoginPriority() {
|
||||
return loginPriority;
|
||||
}
|
||||
|
||||
public void setLoginPriority(int loginPriority) {
|
||||
this.loginPriority = loginPriority;
|
||||
}
|
||||
|
||||
public int getLoginAttributes() {
|
||||
return loginAttributes;
|
||||
}
|
||||
|
||||
public void setLoginAttributes(int loginAttributes) {
|
||||
this.loginAttributes = loginAttributes;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(ChatUnicodeString name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(ChatUnicodeString address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getLoginLocation() {
|
||||
return loginLocation;
|
||||
}
|
||||
|
||||
public void setLoginLocation(ChatUnicodeString loginLocation) {
|
||||
this.loginLocation = loginLocation;
|
||||
}
|
||||
|
||||
}
|
||||
44
src/main/java/chat/protocol/request/RLogoutAvatar.java
Normal file
44
src/main/java/chat/protocol/request/RLogoutAvatar.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RLogoutAvatar extends GenericRequest {
|
||||
|
||||
private int avatarId;
|
||||
private ChatUnicodeString address = new ChatUnicodeString();
|
||||
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
|
||||
public void setAvatarId(int avatarId) {
|
||||
this.avatarId = avatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(ChatUnicodeString address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
avatarId = buf.getInt();
|
||||
address.deserialize(buf);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RRegistrarGetChatServer extends GenericRequest {
|
||||
|
||||
private ChatUnicodeString hostname = new ChatUnicodeString();
|
||||
private short port;
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
hostname.deserialize(buf);
|
||||
setPort(buf.getShort());
|
||||
}
|
||||
|
||||
public short getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(short port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
73
src/main/java/chat/protocol/request/RRemoveBan.java
Normal file
73
src/main/java/chat/protocol/request/RRemoveBan.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RRemoveBan extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destRoomAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
destAvatarName.deserialize(buf);
|
||||
destAvatarAddress.deserialize(buf);
|
||||
destRoomAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarName() {
|
||||
return destAvatarName;
|
||||
}
|
||||
|
||||
public void setDestAvatarName(ChatUnicodeString destAvatarName) {
|
||||
this.destAvatarName = destAvatarName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarAddress() {
|
||||
return destAvatarAddress;
|
||||
}
|
||||
|
||||
public void setDestAvatarAddress(ChatUnicodeString destAvatarAddress) {
|
||||
this.destAvatarAddress = destAvatarAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestRoomAddress() {
|
||||
return destRoomAddress;
|
||||
}
|
||||
|
||||
public void setDestRoomAddress(ChatUnicodeString destRoomAddress) {
|
||||
this.destRoomAddress = destRoomAddress;
|
||||
}
|
||||
|
||||
}
|
||||
63
src/main/java/chat/protocol/request/RRemoveFriend.java
Normal file
63
src/main/java/chat/protocol/request/RRemoveFriend.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RRemoveFriend extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString destName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
destName.deserialize(buf);
|
||||
destAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestName() {
|
||||
return destName;
|
||||
}
|
||||
|
||||
public void setDestName(ChatUnicodeString destName) {
|
||||
this.destName = destName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAddress() {
|
||||
return destAddress;
|
||||
}
|
||||
|
||||
public void setDestAddress(ChatUnicodeString destAddress) {
|
||||
this.destAddress = destAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
}
|
||||
63
src/main/java/chat/protocol/request/RRemoveIgnore.java
Normal file
63
src/main/java/chat/protocol/request/RRemoveIgnore.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RRemoveIgnore extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString destName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
destName.deserialize(buf);
|
||||
destAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestName() {
|
||||
return destName;
|
||||
}
|
||||
|
||||
public void setDestName(ChatUnicodeString destName) {
|
||||
this.destName = destName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAddress() {
|
||||
return destAddress;
|
||||
}
|
||||
|
||||
public void setDestAddress(ChatUnicodeString destAddress) {
|
||||
this.destAddress = destAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
}
|
||||
73
src/main/java/chat/protocol/request/RRemoveInvite.java
Normal file
73
src/main/java/chat/protocol/request/RRemoveInvite.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RRemoveInvite extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destRoomAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
destAvatarName.deserialize(buf);
|
||||
destAvatarAddress.deserialize(buf);
|
||||
destRoomAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarName() {
|
||||
return destAvatarName;
|
||||
}
|
||||
|
||||
public void setDestAvatarName(ChatUnicodeString destAvatarName) {
|
||||
this.destAvatarName = destAvatarName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarAddress() {
|
||||
return destAvatarAddress;
|
||||
}
|
||||
|
||||
public void setDestAvatarAddress(ChatUnicodeString destAvatarAddress) {
|
||||
this.destAvatarAddress = destAvatarAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestRoomAddress() {
|
||||
return destRoomAddress;
|
||||
}
|
||||
|
||||
public void setDestRoomAddress(ChatUnicodeString destRoomAddress) {
|
||||
this.destRoomAddress = destRoomAddress;
|
||||
}
|
||||
|
||||
}
|
||||
73
src/main/java/chat/protocol/request/RRemoveModerator.java
Normal file
73
src/main/java/chat/protocol/request/RRemoveModerator.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RRemoveModerator extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAvatarAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString destRoomAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
destAvatarName.deserialize(buf);
|
||||
destAvatarAddress.deserialize(buf);
|
||||
destRoomAddress.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarName() {
|
||||
return destAvatarName;
|
||||
}
|
||||
|
||||
public void setDestAvatarName(ChatUnicodeString destAvatarName) {
|
||||
this.destAvatarName = destAvatarName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAvatarAddress() {
|
||||
return destAvatarAddress;
|
||||
}
|
||||
|
||||
public void setDestAvatarAddress(ChatUnicodeString destAvatarAddress) {
|
||||
this.destAvatarAddress = destAvatarAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestRoomAddress() {
|
||||
return destRoomAddress;
|
||||
}
|
||||
|
||||
public void setDestRoomAddress(ChatUnicodeString destRoomAddress) {
|
||||
this.destRoomAddress = destRoomAddress;
|
||||
}
|
||||
|
||||
}
|
||||
32
src/main/java/chat/protocol/request/RSendApiVersion.java
Normal file
32
src/main/java/chat/protocol/request/RSendApiVersion.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
|
||||
public class RSendApiVersion extends GenericRequest {
|
||||
|
||||
private int version;
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
version = buf.getInt();
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
}
|
||||
82
src/main/java/chat/protocol/request/RSendInstantMessage.java
Normal file
82
src/main/java/chat/protocol/request/RSendInstantMessage.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RSendInstantMessage extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString destName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString message = new ChatUnicodeString();
|
||||
private ChatUnicodeString oob = new ChatUnicodeString();
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
destName.deserialize(buf);
|
||||
destAddress.deserialize(buf);
|
||||
message.deserialize(buf);
|
||||
oob.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestName() {
|
||||
return destName;
|
||||
}
|
||||
|
||||
public void setDestName(ChatUnicodeString destName) {
|
||||
this.destName = destName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAddress() {
|
||||
return destAddress;
|
||||
}
|
||||
|
||||
public void setDestAddress(ChatUnicodeString destAddress) {
|
||||
this.destAddress = destAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(ChatUnicodeString message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getOob() {
|
||||
return oob;
|
||||
}
|
||||
|
||||
public void setOob(ChatUnicodeString oob) {
|
||||
this.oob = oob;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
}
|
||||
134
src/main/java/chat/protocol/request/RSendPersistentMessage.java
Normal file
134
src/main/java/chat/protocol/request/RSendPersistentMessage.java
Normal file
@@ -0,0 +1,134 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RSendPersistentMessage extends GenericRequest {
|
||||
|
||||
private short avatarPresence;
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destName = new ChatUnicodeString();
|
||||
private ChatUnicodeString destAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString subject = new ChatUnicodeString();
|
||||
private ChatUnicodeString message = new ChatUnicodeString();
|
||||
private ChatUnicodeString oob = new ChatUnicodeString();
|
||||
private ChatUnicodeString category = new ChatUnicodeString();
|
||||
private boolean enforceInboxLimit;
|
||||
private int categoryLimit;
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
avatarPresence = buf.getShort();
|
||||
if(avatarPresence != 0)
|
||||
srcAvatarId = buf.getInt();
|
||||
else
|
||||
srcName.deserialize(buf);
|
||||
destName.deserialize(buf);
|
||||
destAddress.deserialize(buf);
|
||||
subject.deserialize(buf);
|
||||
message.deserialize(buf);
|
||||
oob.deserialize(buf);
|
||||
category.deserialize(buf);
|
||||
enforceInboxLimit = buf.get() != 0;
|
||||
categoryLimit = buf.getInt();
|
||||
}
|
||||
|
||||
public short isAvatarPresence() {
|
||||
return avatarPresence;
|
||||
}
|
||||
|
||||
public void setAvatarPresence(short avatarPresence) {
|
||||
this.avatarPresence = avatarPresence;
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcName() {
|
||||
return srcName;
|
||||
}
|
||||
|
||||
public void setSrcName(ChatUnicodeString srcName) {
|
||||
this.srcName = srcName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestName() {
|
||||
return destName;
|
||||
}
|
||||
|
||||
public void setDestName(ChatUnicodeString destName) {
|
||||
this.destName = destName;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getDestAddress() {
|
||||
return destAddress;
|
||||
}
|
||||
|
||||
public void setDestAddress(ChatUnicodeString destAddress) {
|
||||
this.destAddress = destAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(ChatUnicodeString subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(ChatUnicodeString message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getOob() {
|
||||
return oob;
|
||||
}
|
||||
|
||||
public void setOob(ChatUnicodeString oob) {
|
||||
this.oob = oob;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(ChatUnicodeString category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public boolean isEnforceInboxLimit() {
|
||||
return enforceInboxLimit;
|
||||
}
|
||||
|
||||
public void setEnforceInboxLimit(boolean enforceInboxLimit) {
|
||||
this.enforceInboxLimit = enforceInboxLimit;
|
||||
}
|
||||
|
||||
public int getCategoryLimit() {
|
||||
return categoryLimit;
|
||||
}
|
||||
|
||||
public void setCategoryLimit(int categoryLimit) {
|
||||
this.categoryLimit = categoryLimit;
|
||||
}
|
||||
|
||||
}
|
||||
73
src/main/java/chat/protocol/request/RSendRoomMessage.java
Normal file
73
src/main/java/chat/protocol/request/RSendRoomMessage.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RSendRoomMessage extends GenericRequest {
|
||||
|
||||
private int srcAvatarId;
|
||||
private ChatUnicodeString srcAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString roomAddress = new ChatUnicodeString();
|
||||
private ChatUnicodeString msg = new ChatUnicodeString();
|
||||
private ChatUnicodeString oob = new ChatUnicodeString();
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
srcAvatarId = buf.getInt();
|
||||
roomAddress.deserialize(buf);
|
||||
msg.deserialize(buf);
|
||||
oob.deserialize(buf);
|
||||
srcAddress.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getSrcAvatarId() {
|
||||
return srcAvatarId;
|
||||
}
|
||||
|
||||
public void setSrcAvatarId(int srcAvatarId) {
|
||||
this.srcAvatarId = srcAvatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getSrcAddress() {
|
||||
return srcAddress;
|
||||
}
|
||||
|
||||
public void setSrcAddress(ChatUnicodeString srcAddress) {
|
||||
this.srcAddress = srcAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomAddress() {
|
||||
return roomAddress;
|
||||
}
|
||||
|
||||
public void setRoomAddress(ChatUnicodeString roomAddress) {
|
||||
this.roomAddress = roomAddress;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(ChatUnicodeString msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getOob() {
|
||||
return oob;
|
||||
}
|
||||
|
||||
public void setOob(ChatUnicodeString oob) {
|
||||
this.oob = oob;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package chat.protocol.request;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import chat.protocol.GenericRequest;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class RSetAvatarAttributes extends GenericRequest {
|
||||
|
||||
private int avatarId;
|
||||
private ChatUnicodeString address = new ChatUnicodeString();
|
||||
private int avatarAttributes;
|
||||
private boolean persistent;
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
type = buf.getShort();
|
||||
track = buf.getInt();
|
||||
avatarId = buf.getInt();
|
||||
avatarAttributes = buf.getInt();
|
||||
persistent = buf.get() != 0;
|
||||
//address.deserialize(buf);
|
||||
}
|
||||
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
|
||||
public void setAvatarId(int avatarId) {
|
||||
this.avatarId = avatarId;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(ChatUnicodeString address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public int getAvatarAttributes() {
|
||||
return avatarAttributes;
|
||||
}
|
||||
|
||||
public void setAvatarAttributes(int avatarAttributes) {
|
||||
this.avatarAttributes = avatarAttributes;
|
||||
}
|
||||
|
||||
public boolean isPersistent() {
|
||||
return persistent;
|
||||
}
|
||||
|
||||
public void setPersistent(boolean persistent) {
|
||||
this.persistent = persistent;
|
||||
}
|
||||
|
||||
}
|
||||
41
src/main/java/chat/protocol/response/ResAddBan.java
Normal file
41
src/main/java/chat/protocol/response/ResAddBan.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResAddBan extends GenericResponse {
|
||||
|
||||
private int destRoomId;
|
||||
|
||||
public ResAddBan() {
|
||||
type = RESPONSE_ADDBAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(destRoomId);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
}
|
||||
30
src/main/java/chat/protocol/response/ResAddFriend.java
Normal file
30
src/main/java/chat/protocol/response/ResAddFriend.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResAddFriend extends GenericResponse {
|
||||
|
||||
public ResAddFriend() {
|
||||
type = RESPONSE_ADDFRIEND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(14).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
30
src/main/java/chat/protocol/response/ResAddIgnore.java
Normal file
30
src/main/java/chat/protocol/response/ResAddIgnore.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResAddIgnore extends GenericResponse {
|
||||
|
||||
public ResAddIgnore() {
|
||||
type = RESPONSE_ADDIGNORE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(14).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
41
src/main/java/chat/protocol/response/ResAddInvite.java
Normal file
41
src/main/java/chat/protocol/response/ResAddInvite.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResAddInvite extends GenericResponse {
|
||||
|
||||
private int destRoomId;
|
||||
|
||||
public ResAddInvite() {
|
||||
type = RESPONSE_ADDINVITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(destRoomId);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
}
|
||||
41
src/main/java/chat/protocol/response/ResAddModerator.java
Normal file
41
src/main/java/chat/protocol/response/ResAddModerator.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResAddModerator extends GenericResponse {
|
||||
|
||||
private int destRoomId;
|
||||
|
||||
public ResAddModerator() {
|
||||
type = RESPONSE_ADDMODERATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(destRoomId);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
}
|
||||
80
src/main/java/chat/protocol/response/ResCreateRoom.java
Normal file
80
src/main/java/chat/protocol/response/ResCreateRoom.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import chat.ChatRoom;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResCreateRoom extends GenericResponse {
|
||||
|
||||
private ChatRoom room;
|
||||
private List<ChatRoom> extraRooms = new ArrayList<ChatRoom>();
|
||||
|
||||
public ResCreateRoom() {
|
||||
type = RESPONSE_CREATEROOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
List<byte[]> roomBufs = new ArrayList<>();
|
||||
int roomBufsSize = 0;
|
||||
for(ChatRoom room : extraRooms) {
|
||||
byte[] roomBuf = room.serialize();
|
||||
roomBufsSize += roomBuf.length;
|
||||
roomBufs.add(roomBuf);
|
||||
}
|
||||
int roomSize = 0;
|
||||
byte[] roomBuf = null;
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS) {
|
||||
roomBuf = room.serialize();
|
||||
roomSize = roomBuf.length;
|
||||
}
|
||||
ByteBuffer buf;
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS)
|
||||
buf = ByteBuffer.allocate(18 + roomBufsSize + roomSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
else
|
||||
buf = ByteBuffer.allocate(14 + roomBufsSize + roomSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS) {
|
||||
buf.put(roomBuf);
|
||||
buf.putInt(extraRooms.size());
|
||||
for(byte[] sumBuf : roomBufs) {
|
||||
buf.put(sumBuf);
|
||||
}
|
||||
}
|
||||
writeSize(buf); freeNative(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
private void freeNative(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public ChatRoom getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
public void setRoom(ChatRoom room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public List<ChatRoom> getExtraRooms() {
|
||||
return extraRooms;
|
||||
}
|
||||
|
||||
public void setExtraRooms(List<ChatRoom> extraRooms) {
|
||||
this.extraRooms = extraRooms;
|
||||
}
|
||||
|
||||
}
|
||||
30
src/main/java/chat/protocol/response/ResDestroyAvatar.java
Normal file
30
src/main/java/chat/protocol/response/ResDestroyAvatar.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResDestroyAvatar extends GenericResponse {
|
||||
|
||||
public ResDestroyAvatar() {
|
||||
type = RESPONSE_DESTROYAVATAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(14).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
46
src/main/java/chat/protocol/response/ResDestroyRoom.java
Normal file
46
src/main/java/chat/protocol/response/ResDestroyRoom.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResDestroyRoom extends GenericResponse {
|
||||
|
||||
private int destRoomId;
|
||||
|
||||
public ResDestroyRoom() {
|
||||
type = RESPONSE_DESTROYROOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(destRoomId);
|
||||
writeSize(buf);freeNative(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
private void freeNative(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
}
|
||||
93
src/main/java/chat/protocol/response/ResEnterRoom.java
Normal file
93
src/main/java/chat/protocol/response/ResEnterRoom.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import chat.ChatRoom;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResEnterRoom extends GenericResponse {
|
||||
|
||||
private ChatRoom room;
|
||||
private List<ChatRoom> extraRooms = new ArrayList<ChatRoom>();
|
||||
private int roomId;
|
||||
private boolean gotRoom = false;
|
||||
|
||||
public ResEnterRoom() {
|
||||
type = RESPONSE_ENTERROOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
List<byte[]> roomBufs = new ArrayList<>();
|
||||
int roomBufsSize = 0;
|
||||
for(ChatRoom room : extraRooms) {
|
||||
byte[] roomBuf = room.serialize();
|
||||
roomBufsSize += roomBuf.length;
|
||||
roomBufs.add(roomBuf);
|
||||
}
|
||||
int roomSize = 0;
|
||||
byte[] roomBuf = null;
|
||||
if(gotRoom) {
|
||||
roomBuf = room.serialize();
|
||||
roomSize = roomBuf.length;
|
||||
}
|
||||
ByteBuffer buf = ByteBuffer.allocate(23 + roomBufsSize + roomSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(roomId);
|
||||
buf.put((byte) (gotRoom ? 1 : 0));
|
||||
if(gotRoom) {
|
||||
buf.put(roomBuf);
|
||||
buf.putInt(extraRooms.size());
|
||||
for(byte[] sumBuf : roomBufs) {
|
||||
buf.put(sumBuf);
|
||||
}
|
||||
}
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public ChatRoom getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
public void setRoom(ChatRoom room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public List<ChatRoom> getExtraRooms() {
|
||||
return extraRooms;
|
||||
}
|
||||
|
||||
public void setExtraRooms(List<ChatRoom> extraRooms) {
|
||||
this.extraRooms = extraRooms;
|
||||
}
|
||||
|
||||
public int getRoomId() {
|
||||
return roomId;
|
||||
}
|
||||
|
||||
public void setRoomId(int roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
public boolean isGotRoom() {
|
||||
return gotRoom;
|
||||
}
|
||||
|
||||
public void setGotRoom(boolean gotRoom) {
|
||||
this.gotRoom = gotRoom;
|
||||
}
|
||||
|
||||
}
|
||||
49
src/main/java/chat/protocol/response/ResFailLoginAvatar.java
Normal file
49
src/main/java/chat/protocol/response/ResFailLoginAvatar.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import chat.ChatAvatar;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResFailLoginAvatar extends GenericResponse {
|
||||
|
||||
private ChatAvatar avatar;
|
||||
|
||||
public ResFailLoginAvatar() {
|
||||
type = RESPONSE_FAILOVER_RELOGINAVATAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
byte[] avatarBuf = avatar.serialize();
|
||||
ByteBuffer buf = ByteBuffer.allocate(14 + avatarBuf.length).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS) {
|
||||
buf.put(avatarBuf);
|
||||
// These are optional and not used for SWG
|
||||
//buf.putInt(requiredLoginPriority);
|
||||
//buf.put(email.serialize());
|
||||
//buf.putInt(inboxLimit);
|
||||
}
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public ChatAvatar getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(ChatAvatar avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import chat.ChatRoom;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResFailoverRecreateRoom extends GenericResponse {
|
||||
|
||||
private ChatRoom room;
|
||||
private List<ChatRoom> extraRooms = new ArrayList<ChatRoom>();
|
||||
private boolean gotRoom = false;
|
||||
|
||||
public ResFailoverRecreateRoom() {
|
||||
type = RESPONSE_FAILOVER_RECREATEROOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
List<byte[]> roomBufs = new ArrayList<>();
|
||||
int roomBufsSize = 0;
|
||||
for(ChatRoom room : extraRooms) {
|
||||
byte[] roomBuf = room.serialize();
|
||||
roomBufsSize += roomBuf.length;
|
||||
roomBufs.add(roomBuf);
|
||||
//System.out.println("roomBuf " + roomBuf);
|
||||
}
|
||||
int roomSize = 0;
|
||||
byte[] roomBuf = null;
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS) {
|
||||
roomBuf = room.serialize();
|
||||
roomSize = roomBuf.length;
|
||||
}
|
||||
ByteBuffer buf;
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS)
|
||||
buf = ByteBuffer.allocate(18 + roomBufsSize + roomSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
else
|
||||
buf = ByteBuffer.allocate(14 + roomBufsSize + roomSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS) {
|
||||
buf.put(roomBuf);
|
||||
buf.putInt(extraRooms.size());
|
||||
for(byte[] sumBuf : roomBufs) {
|
||||
buf.put(sumBuf);
|
||||
}
|
||||
}
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public ChatRoom getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
public void setRoom(ChatRoom room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public List<ChatRoom> getExtraRooms() {
|
||||
return extraRooms;
|
||||
}
|
||||
|
||||
public void setExtraRooms(List<ChatRoom> extraRooms) {
|
||||
this.extraRooms = extraRooms;
|
||||
}
|
||||
|
||||
public void setGotRoom(boolean gotRoom) {
|
||||
this.gotRoom = gotRoom;
|
||||
}
|
||||
|
||||
}
|
||||
54
src/main/java/chat/protocol/response/ResFriendStatus.java
Normal file
54
src/main/java/chat/protocol/response/ResFriendStatus.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import chat.ChatFriend;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResFriendStatus extends GenericResponse {
|
||||
|
||||
private List<ChatFriend> friendsList;
|
||||
|
||||
public ResFriendStatus() {
|
||||
type = RESPONSE_FRIENDSTATUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
List<byte[]> friendBufs = new ArrayList<>();
|
||||
int friendBufsSize = 0;
|
||||
for(ChatFriend friend : friendsList) {
|
||||
byte[] friendBuf = friend.serialize();
|
||||
friendBufsSize += friendBuf.length;
|
||||
friendBufs.add(friendBuf);
|
||||
}
|
||||
ByteBuffer buf = ByteBuffer.allocate(18 + friendBufsSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(friendBufs.size());
|
||||
for(byte[] friendBuf : friendBufs)
|
||||
buf.put(friendBuf);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public List<ChatFriend> getFriendsList() {
|
||||
return friendsList;
|
||||
}
|
||||
|
||||
public void setFriendsList(List<ChatFriend> friendsList) {
|
||||
this.friendsList = friendsList;
|
||||
}
|
||||
|
||||
}
|
||||
63
src/main/java/chat/protocol/response/ResGetAnyAvatar.java
Normal file
63
src/main/java/chat/protocol/response/ResGetAnyAvatar.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.ChatAvatar;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResGetAnyAvatar extends GenericResponse {
|
||||
|
||||
private ChatAvatar avatar;
|
||||
private boolean isLoggedIn;
|
||||
|
||||
public ResGetAnyAvatar() {
|
||||
type = RESPONSE_GETANYAVATAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS) {
|
||||
byte[] avatarBuf = avatar.serialize();
|
||||
ByteBuffer buf = ByteBuffer.allocate(15 + avatarBuf.length).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.put((byte) (isLoggedIn ? 1 : 0));
|
||||
buf.put(avatarBuf);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
} else {
|
||||
ByteBuffer buf = ByteBuffer.allocate(15).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.put((byte) (isLoggedIn ? 1 : 0));
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
}
|
||||
|
||||
public ChatAvatar getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(ChatAvatar avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public boolean isLoggedIn() {
|
||||
return isLoggedIn;
|
||||
}
|
||||
|
||||
public void setLoggedIn(boolean isLoggedIn) {
|
||||
this.isLoggedIn = isLoggedIn;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import chat.PersistentMessage;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResGetPersistentHeaders extends GenericResponse {
|
||||
|
||||
private List<PersistentMessage> pmList = new ArrayList<>();
|
||||
|
||||
public ResGetPersistentHeaders() {
|
||||
type = RESPONSE_GETPERSISTENTHEADERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
List<byte[]> pmBuffers = new ArrayList<>();
|
||||
int pmBufSize = 0;
|
||||
for(PersistentMessage pm : pmList) {
|
||||
byte[] pmBuf = pm.serializeHeader();
|
||||
pmBufSize += pmBuf.length;
|
||||
pmBuffers.add(pmBuf);
|
||||
}
|
||||
ByteBuffer buf = ByteBuffer.allocate(18 + pmBufSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(pmList.size());
|
||||
for(byte[] pmBuf : pmBuffers)
|
||||
buf.put(pmBuf);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public List<PersistentMessage> getPmList() {
|
||||
return pmList;
|
||||
}
|
||||
|
||||
public void setPmList(List<PersistentMessage> pmList) {
|
||||
this.pmList = pmList;
|
||||
}
|
||||
|
||||
public void addPersistentMessage(PersistentMessage pm) {
|
||||
pmList.add(pm);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.PersistentMessage;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResGetPersistentMessage extends GenericResponse {
|
||||
|
||||
private PersistentMessage pm;
|
||||
|
||||
public ResGetPersistentMessage() {
|
||||
type = RESPONSE_GETPERSISTENTMESSAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
byte[] pmBuf = null;
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS)
|
||||
pmBuf = pm.serialize();
|
||||
ByteBuffer buf = ByteBuffer.allocate(pmBuf == null ? 14 : (14 + pmBuf.length)).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS)
|
||||
buf.put(pmBuf);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public PersistentMessage getPm() {
|
||||
return pm;
|
||||
}
|
||||
|
||||
public void setPm(PersistentMessage pm) {
|
||||
this.pm = pm;
|
||||
}
|
||||
|
||||
}
|
||||
77
src/main/java/chat/protocol/response/ResGetRoom.java
Normal file
77
src/main/java/chat/protocol/response/ResGetRoom.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import chat.ChatRoom;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResGetRoom extends GenericResponse {
|
||||
|
||||
private ChatRoom room;
|
||||
private List<ChatRoom> extraRooms = new ArrayList<ChatRoom>();
|
||||
|
||||
public ResGetRoom() {
|
||||
type = RESPONSE_GETROOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
List<byte[]> roomBufs = new ArrayList<>();
|
||||
int roomBufsSize = 0;
|
||||
for(ChatRoom room : extraRooms) {
|
||||
byte[] roomBuf = room.serialize();
|
||||
roomBufsSize += roomBuf.length;
|
||||
roomBufs.add(roomBuf);
|
||||
}
|
||||
int roomSize = 0;
|
||||
byte[] roomBuf = null;
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS) {
|
||||
roomBuf = room.serialize();
|
||||
roomSize = roomBuf.length;
|
||||
}
|
||||
ByteBuffer buf;
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS)
|
||||
buf = ByteBuffer.allocate(18 + roomBufsSize + roomSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
else
|
||||
buf = ByteBuffer.allocate(14 + roomBufsSize + roomSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS) {
|
||||
buf.put(roomBuf);
|
||||
buf.putInt(extraRooms.size());
|
||||
for(byte[] sumBuf : roomBufs) {
|
||||
buf.put(sumBuf);
|
||||
}
|
||||
}
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public ChatRoom getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
public void setRoom(ChatRoom room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public List<ChatRoom> getExtraRooms() {
|
||||
return extraRooms;
|
||||
}
|
||||
|
||||
public void setExtraRooms(List<ChatRoom> extraRooms) {
|
||||
this.extraRooms = extraRooms;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import chat.ChatRoom;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResGetRoomSummaries extends GenericResponse {
|
||||
|
||||
private List<ChatRoom> rooms;
|
||||
|
||||
public ResGetRoomSummaries() {
|
||||
type = RESPONSE_GETROOMSUMMARIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
List<byte[]> sumBufs = new ArrayList<>();
|
||||
int sumBufsSize = 0;
|
||||
for(ChatRoom room : rooms) {
|
||||
byte[] sumBuf = room.serializeSummary();
|
||||
sumBufsSize += sumBuf.length;
|
||||
sumBufs.add(sumBuf);
|
||||
}
|
||||
ByteBuffer buf = ByteBuffer.allocate(18 + sumBufsSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(rooms.size());
|
||||
for(byte[] sumBuf : sumBufs) {
|
||||
buf.put(sumBuf);
|
||||
}
|
||||
writeSize(buf);freeNative(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
private void freeNative(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public List<ChatRoom> getRooms() {
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public void setRooms(List<ChatRoom> rooms) {
|
||||
this.rooms = rooms;
|
||||
}
|
||||
|
||||
}
|
||||
53
src/main/java/chat/protocol/response/ResIgnoreStatus.java
Normal file
53
src/main/java/chat/protocol/response/ResIgnoreStatus.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import chat.ChatIgnore;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResIgnoreStatus extends GenericResponse {
|
||||
|
||||
private List<ChatIgnore> ignoreList;
|
||||
|
||||
public ResIgnoreStatus() {
|
||||
type = RESPONSE_IGNORESTATUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
List<byte[]> ignoreBufs = new ArrayList<>();
|
||||
int ignoreBufsSize = 0;
|
||||
for(ChatIgnore ignore : ignoreList) {
|
||||
byte[] ignoreBuf = ignore.serialize();
|
||||
ignoreBufsSize += ignoreBuf.length;
|
||||
ignoreBufs.add(ignoreBuf);
|
||||
}
|
||||
ByteBuffer buf = ByteBuffer.allocate(18 + ignoreBufsSize).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(ignoreBufs.size());
|
||||
for(byte[] ignoreBuf : ignoreBufs)
|
||||
buf.put(ignoreBuf);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public List<ChatIgnore> getIgnoreList() {
|
||||
return ignoreList;
|
||||
}
|
||||
|
||||
public void setIgnoreList(List<ChatIgnore> ignoreList) {
|
||||
this.ignoreList = ignoreList;
|
||||
}
|
||||
|
||||
}
|
||||
41
src/main/java/chat/protocol/response/ResKickAvatar.java
Normal file
41
src/main/java/chat/protocol/response/ResKickAvatar.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResKickAvatar extends GenericResponse {
|
||||
|
||||
private int destRoomId;
|
||||
|
||||
public ResKickAvatar() {
|
||||
type = RESPONSE_KICKAVATAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(destRoomId);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
}
|
||||
60
src/main/java/chat/protocol/response/ResLeaveRoom.java
Normal file
60
src/main/java/chat/protocol/response/ResLeaveRoom.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import chat.ChatRoom;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResLeaveRoom extends GenericResponse {
|
||||
|
||||
private int destRoomId;
|
||||
private List<ChatRoom> extraRooms = new ArrayList<ChatRoom>();
|
||||
private int roomId;
|
||||
private boolean gotRoom = true;
|
||||
|
||||
public ResLeaveRoom() {
|
||||
type = RESPONSE_LEAVEROOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
//buf.putInt(srcAvatarId);
|
||||
buf.putInt(roomId);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
public void setGotRoom(boolean b) {
|
||||
this.gotRoom = gotRoom;
|
||||
|
||||
}
|
||||
public boolean isGotRoom() {
|
||||
return gotRoom;
|
||||
}
|
||||
|
||||
public void setRoomId(int roomId) {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
}
|
||||
49
src/main/java/chat/protocol/response/ResLoginAvatar.java
Normal file
49
src/main/java/chat/protocol/response/ResLoginAvatar.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import chat.ChatAvatar;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResLoginAvatar extends GenericResponse {
|
||||
|
||||
private ChatAvatar avatar;
|
||||
|
||||
public ResLoginAvatar() {
|
||||
type = RESPONSE_LOGINAVATAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
byte[] avatarBuf = avatar.serialize();
|
||||
ByteBuffer buf = ByteBuffer.allocate(14 + avatarBuf.length).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS) {
|
||||
buf.put(avatarBuf);
|
||||
// These are optional and not used for SWG
|
||||
//buf.putInt(requiredLoginPriority);
|
||||
//buf.put(email.serialize());
|
||||
//buf.putInt(inboxLimit);
|
||||
}
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public ChatAvatar getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(ChatAvatar avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
30
src/main/java/chat/protocol/response/ResLogoutAvatar.java
Normal file
30
src/main/java/chat/protocol/response/ResLogoutAvatar.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResLogoutAvatar extends GenericResponse {
|
||||
|
||||
public ResLogoutAvatar() {
|
||||
type = RESPONSE_LOGOUTAVATAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(14).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import chat.protocol.GenericResponse;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class ResRegistrarGetChatServer extends GenericResponse {
|
||||
|
||||
private ChatUnicodeString hostname;
|
||||
private short port;
|
||||
|
||||
public ResRegistrarGetChatServer() {
|
||||
type = GenericResponse.RESPONSE_REGISTRAR_GETCHATSERVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(20 + hostname.getStringLength() * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.put(hostname.serialize());
|
||||
buf.putShort(port);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public ChatUnicodeString getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
public void setHostname(ChatUnicodeString hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
public short getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(short port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
}
|
||||
41
src/main/java/chat/protocol/response/ResRemoveBan.java
Normal file
41
src/main/java/chat/protocol/response/ResRemoveBan.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResRemoveBan extends GenericResponse {
|
||||
|
||||
private int destRoomId;
|
||||
|
||||
public ResRemoveBan() {
|
||||
type = RESPONSE_REMOVEBAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(destRoomId);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
}
|
||||
30
src/main/java/chat/protocol/response/ResRemoveFriend.java
Normal file
30
src/main/java/chat/protocol/response/ResRemoveFriend.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResRemoveFriend extends GenericResponse {
|
||||
|
||||
public ResRemoveFriend() {
|
||||
type = RESPONSE_REMOVEFRIEND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(14).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
30
src/main/java/chat/protocol/response/ResRemoveIgnore.java
Normal file
30
src/main/java/chat/protocol/response/ResRemoveIgnore.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResRemoveIgnore extends GenericResponse {
|
||||
|
||||
public ResRemoveIgnore() {
|
||||
type = RESPONSE_REMOVEIGNORE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(14).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
41
src/main/java/chat/protocol/response/ResRemoveInvite.java
Normal file
41
src/main/java/chat/protocol/response/ResRemoveInvite.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResRemoveInvite extends GenericResponse {
|
||||
|
||||
private int destRoomId;
|
||||
|
||||
public ResRemoveInvite() {
|
||||
type = RESPONSE_REMOVEINVITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(destRoomId);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
}
|
||||
41
src/main/java/chat/protocol/response/ResRemoveModerator.java
Normal file
41
src/main/java/chat/protocol/response/ResRemoveModerator.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResRemoveModerator extends GenericResponse {
|
||||
|
||||
private int destRoomId;
|
||||
|
||||
public ResRemoveModerator() {
|
||||
type = RESPONSE_REMOVEMODERATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(destRoomId);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
}
|
||||
42
src/main/java/chat/protocol/response/ResSendApiVersion.java
Normal file
42
src/main/java/chat/protocol/response/ResSendApiVersion.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResSendApiVersion extends GenericResponse {
|
||||
|
||||
private int version;
|
||||
|
||||
public ResSendApiVersion() {
|
||||
type = RESPONSE_SETAPIVERSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(version);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResSendInstantMessage extends GenericResponse {
|
||||
|
||||
public ResSendInstantMessage() {
|
||||
type = RESPONSE_SENDINSTANTMESSAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(14).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResSendPersistentMessage extends GenericResponse {
|
||||
|
||||
private int messageId;
|
||||
|
||||
public ResSendPersistentMessage() {
|
||||
type = RESPONSE_SENDPERSISTENTMESSAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(result == ResponseResult.CHATRESULT_SUCCESS ? 18 : 14).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS)
|
||||
buf.putInt(messageId);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public void setMessageId(int messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
}
|
||||
41
src/main/java/chat/protocol/response/ResSendRoomMessage.java
Normal file
41
src/main/java/chat/protocol/response/ResSendRoomMessage.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResSendRoomMessage extends GenericResponse {
|
||||
|
||||
private int destRoomId;
|
||||
|
||||
public ResSendRoomMessage() {
|
||||
type = RESPONSE_SENDROOMMESSAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.putInt(destRoomId);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.ChatAvatar;
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResSetAvatarAttributes extends GenericResponse {
|
||||
|
||||
private ChatAvatar avatar;
|
||||
|
||||
public ResSetAvatarAttributes() {
|
||||
type = RESPONSE_SETAVATARATTRIBUTES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
if(result == ResponseResult.CHATRESULT_SUCCESS) {
|
||||
byte[] avatarBuf = avatar.serialize();
|
||||
ByteBuffer buf = ByteBuffer.allocate(14 + avatarBuf.length).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
buf.put(avatarBuf);
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
} else {
|
||||
ByteBuffer buf = ByteBuffer.allocate(14).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
}
|
||||
|
||||
public ChatAvatar getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(ChatAvatar avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
}
|
||||
62
src/main/java/chat/protocol/response/ResUnregisterRoom.java
Normal file
62
src/main/java/chat/protocol/response/ResUnregisterRoom.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.ChatRoom;
|
||||
import chat.protocol.GenericResponse;
|
||||
import chat.util.ChatUnicodeString;
|
||||
|
||||
public class ResUnregisterRoom extends GenericResponse {
|
||||
|
||||
private int destRoomId;
|
||||
private ChatRoom destRoom;
|
||||
private ChatUnicodeString roomAddress = new ChatUnicodeString();
|
||||
|
||||
public ResUnregisterRoom() {
|
||||
type = RESPONSE_UNREGISTERROOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track+1);
|
||||
buf.putInt(result.ordinal());
|
||||
roomAddress.deserialize(buf);
|
||||
writeSize(buf);freeNative(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
private void freeNative(ByteBuffer buf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
public int getDestRoomId() {
|
||||
return destRoomId;
|
||||
}
|
||||
|
||||
public ChatRoom getDestRoom() {
|
||||
return destRoom;
|
||||
}
|
||||
|
||||
public ChatUnicodeString getRoomAddress() {
|
||||
return roomAddress;
|
||||
}
|
||||
|
||||
public void setRoomAddress(ChatUnicodeString roomAddress) {
|
||||
this.roomAddress = roomAddress;
|
||||
}
|
||||
|
||||
public void setDestRoomId(int destRoomId) {
|
||||
this.destRoomId = destRoomId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResUpdatePersistentMessage extends GenericResponse {
|
||||
|
||||
public ResUpdatePersistentMessage() {
|
||||
type = RESPONSE_UPDATEPERSISTENTMESSAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(14).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import chat.protocol.GenericResponse;
|
||||
|
||||
public class ResUpdatePersistentMessages extends GenericResponse {
|
||||
|
||||
public ResUpdatePersistentMessages() {
|
||||
type = RESPONSE_UPDATEPERSISTENTMESSAGES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer serialize() {
|
||||
ByteBuffer buf = ByteBuffer.allocate(14).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(0);
|
||||
buf.putShort(type);
|
||||
buf.putInt(track);
|
||||
buf.putInt(result.ordinal());
|
||||
writeSize(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
81
src/main/java/chat/protocol/response/ResponseResult.java
Normal file
81
src/main/java/chat/protocol/response/ResponseResult.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package chat.protocol.response;
|
||||
|
||||
public enum ResponseResult {
|
||||
|
||||
CHATRESULT_SUCCESS,
|
||||
CHATRESULT_TIMEOUT,
|
||||
CHATRESULT_DUPLICATELOGIN,
|
||||
CHATRESULT_SRCAVATARDOESNTEXIST,
|
||||
CHATRESULT_DESTAVATARDOESNTEXIST,
|
||||
CHATRESULT_ADDRESSDOESNTEXIST,
|
||||
CHATRESULT_ADDRESSNOTROOM,
|
||||
CHATRESULT_ADDRESSNOTAID,
|
||||
CHATRESULT_FRIENDNOTFOUND,
|
||||
CHATRESULT_ROOM_UNKNOWNFAILURE,
|
||||
CHATRESULT_ROOM_SRCNOTINROOM,
|
||||
CHATRESULT_ROOM_DESTNOTINROOM,
|
||||
CHATRESULT_ROOM_BANNEDAVATAR,
|
||||
CHATRESULT_ROOM_PRIVATEROOM,
|
||||
CHATRESULT_ROOM_MODERATEDROOM,
|
||||
CHATRESULT_ROOM_NOTINROOM,
|
||||
CHATRESULT_ROOM_NOPRIVILEGES,
|
||||
CHATRESULT_DATABASE,
|
||||
CHATRESULT_CANNOTGETAVATARID,
|
||||
CHATRESULT_CANNOTGETNODEID,
|
||||
CHATRESULT_CANNOTGETPMSGID,
|
||||
CHATRESULT_PMSGNOTFOUND,
|
||||
CHATRESULT_ROOMMAXAVATARSREACHED,
|
||||
CHATRESULT_IGNORING,
|
||||
CHATRESULT_ROOM_ALREADYEXISTS,
|
||||
CHATRESULT_NOTHINGTOCONFIRM,
|
||||
CHATRESULT_DUPLICATEFRIEND,
|
||||
CHATRESULT_IGNORENOTFOUND,
|
||||
CHATRESULT_DUPLICATEIGNORE,
|
||||
CHATRESULT_DBFAIL,
|
||||
CHATRESULT_ROOM_DESTAVATARISMODERATOR,
|
||||
CHATRESULT_ROOM_DESTAVATARNOTINVITED,
|
||||
CHATRESULT_ROOM_AVATARNOTINVITED,
|
||||
CHATRESULT_ROOM_DESTAVATARISINVITED,
|
||||
CHATRESULT_ROOM_DESTAVATARNOTBANNED,
|
||||
CHATRESULT_ROOM_DUPLICATEBAN,
|
||||
CHATRESULT_ROOM_DUPLICATEMODERATOR,
|
||||
CHATRESULT_ROOM_DUPLICATEINVITE,
|
||||
CHATRESULT_ROOM_ALREADYINROOM,
|
||||
CHATRESULT_ROOM_PARENTNONPERSISTENT,
|
||||
CHATRESULT_ROOM_PARENTBADNODETYPE,
|
||||
CHATRESULT_NOFANCLUBHANDLE,
|
||||
CHATRESULT_AIDALREADYEXISTS,
|
||||
CHATRESULT_UIDALREADYEXISTS,
|
||||
CHATRESULT_WRONGCHATSERVERFORREQUEST,
|
||||
CHATRESULT_SUCCESSBADDATA,
|
||||
CHATRESULT_NULLNAMELOGIN,
|
||||
CHATRESULT_SERVER_IDENTITY_EMPTY,
|
||||
CHATRESULT_SERVER_IDENTITY_TAKEN,
|
||||
CHATRESULT_REMOTESERVERDOWN,
|
||||
CHATRESULT_NODEIDCONFLICT,
|
||||
CHATRESULT_INVALIDNODENAME,
|
||||
CHATRESULT_INSUFFICIENTGMPRIVS,
|
||||
CHATRESULT_SNOOPALREADYADDED,
|
||||
CHATRESULT_NOTSNOOPING,
|
||||
CHATRESULT_ROOM_DESTAVATARNOTTEMPORARYMODERATOR,
|
||||
CHATRESULT_ROOM_DESTAVATARNOTVOICE,
|
||||
CHATRESULT_ROOM_DUPLICATETEMPORARYMODERATOR,
|
||||
CHATRESULT_ROOM_DUPLICATEVOICE,
|
||||
CHATRESULT_AVATARMUSTBELOGGEDOUT,
|
||||
CHATRESULT_NOTHINGTODO,
|
||||
CHATRESULT_TRANSFERNAMENULL,
|
||||
CHATRESULT_TRANSFERUSERIDZERO,
|
||||
CHATRESULT_TRANSFERADDRESSNULL,
|
||||
CHATRESULT_OUTOFIDS,
|
||||
CHATRESULT_ROOM_LOCALROOM,
|
||||
CHATRESULT_ROOM_GAMEROOM,
|
||||
CHATRESULT_ROOM_DESTAVATARNOTENTERING,
|
||||
CHATRESULT_INSUFFICIENTPRIORITY,
|
||||
CHATRESULT_ROOM_WAITINGFORENTRY,
|
||||
CHATRESULT_INBOXLIMITEXCEEDED,
|
||||
CHATRESULT_DUPLICATEDESTINATION,
|
||||
CHATRESULT_CATEGORYLIMITEXCEEDED,
|
||||
CHATRESULT_MESSAGE_FILTER_FAILURE,
|
||||
CHATRESULT_INVALID_INPUT,
|
||||
|
||||
}
|
||||
50
src/main/java/chat/util/ChatUnicodeString.java
Normal file
50
src/main/java/chat/util/ChatUnicodeString.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package chat.util;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class ChatUnicodeString {
|
||||
|
||||
private String string;
|
||||
|
||||
public ChatUnicodeString(String string) {
|
||||
setString(string);
|
||||
}
|
||||
|
||||
public ChatUnicodeString() {
|
||||
string = new String();
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
|
||||
public void setString(String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
public byte[] serialize() {
|
||||
int length = getStringLength();
|
||||
ByteBuffer buf = ByteBuffer.allocate(4 + length * 2).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.putInt(length);
|
||||
buf.put(string.getBytes(StandardCharsets.UTF_16LE));
|
||||
return buf.array();
|
||||
}
|
||||
|
||||
public void deserialize(ByteBuffer buf) {
|
||||
int length = buf.getInt();
|
||||
byte [] data = new byte[length * 2];
|
||||
buf.get(data);
|
||||
string = new String(data, StandardCharsets.UTF_16LE);
|
||||
}
|
||||
|
||||
public int getStringLength() {
|
||||
return string.length();
|
||||
}
|
||||
|
||||
public boolean equals(ChatUnicodeString string) {
|
||||
return getString().equals(string.getString());
|
||||
}
|
||||
|
||||
}
|
||||
141
src/main/java/chat/util/Config.java
Normal file
141
src/main/java/chat/util/Config.java
Normal file
@@ -0,0 +1,141 @@
|
||||
package chat.util;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.util.Properties;
|
||||
|
||||
/*! Reads and stores configuration data from a file */
|
||||
public class Config {
|
||||
|
||||
Properties configData;
|
||||
|
||||
String filePath;
|
||||
|
||||
public Config() {
|
||||
initialize();
|
||||
};
|
||||
|
||||
public Config(String filename) {
|
||||
initialize();
|
||||
setFilePath(filename);
|
||||
loadConfigFile(getFilePath());
|
||||
}
|
||||
|
||||
/* ! Displays the current filePath and the key:value pairs of configData */
|
||||
public void displayData() {
|
||||
System.out.println("File Path: " + getFilePath());
|
||||
configData.list(System.out);
|
||||
}
|
||||
|
||||
public boolean keyExists(String key) {
|
||||
return (configData.getProperty(key) != null);
|
||||
}
|
||||
|
||||
public double getDouble(String key) {
|
||||
return Double.parseDouble(getString(key));
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return this.filePath;
|
||||
}
|
||||
|
||||
public int getInt(String key) {
|
||||
return Integer.parseInt(getString(key));
|
||||
}
|
||||
|
||||
public byte getByte(String key) {
|
||||
return Byte.parseByte(getString(key));
|
||||
}
|
||||
|
||||
public String getProperty(String key) {
|
||||
return configData.getProperty(key);
|
||||
}
|
||||
|
||||
public String getString(String key) {
|
||||
return getProperty(key);
|
||||
}
|
||||
|
||||
public boolean getBoolean(String key) {
|
||||
return Boolean.valueOf(getString(key));
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
configData = new Properties();
|
||||
}
|
||||
|
||||
public boolean loadConfigFile() {
|
||||
|
||||
if (getFilePath() == null || getFilePath().isEmpty()) {
|
||||
System.err
|
||||
.println("Config.java loadConfigFile(): Attempted to load from a null or empty file path.");
|
||||
return false;
|
||||
} else
|
||||
return loadConfigFile(getFilePath());
|
||||
}
|
||||
|
||||
public boolean loadConfigFile(String filename) {
|
||||
|
||||
FileReader reader;
|
||||
|
||||
try {
|
||||
|
||||
reader = new FileReader(filename);
|
||||
synchronized (reader) {
|
||||
configData = new Properties();
|
||||
configData.load(reader);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public boolean saveConfig() {
|
||||
if (getFilePath() == null || getFilePath().isEmpty()) {
|
||||
System.err
|
||||
.println("Config.java saveConfig(): Attempted to save configuration to a null or empty filepath.");
|
||||
return false;
|
||||
} else {
|
||||
return saveConfig(getFilePath());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean saveConfig(String filename) {
|
||||
FileWriter writer;
|
||||
try {
|
||||
writer = new FileWriter(filename);
|
||||
synchronized (writer) {
|
||||
configData.store(writer, null);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFilePath(String filename) {
|
||||
this.filePath = filename;
|
||||
}
|
||||
|
||||
public void setProperty(String key, double value) {
|
||||
String v = "" + value;
|
||||
setProperty(key, v);
|
||||
}
|
||||
|
||||
public void setProperty(String key, int value) {
|
||||
String v = "" + value;
|
||||
setProperty(key, v);
|
||||
}
|
||||
|
||||
public void setProperty(String key, String value) {
|
||||
configData.setProperty(key, value);
|
||||
saveConfig();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
12
src/main/java/chat/util/PersistentAlterationStatus.java
Normal file
12
src/main/java/chat/util/PersistentAlterationStatus.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package chat.util;
|
||||
|
||||
public class PersistentAlterationStatus {
|
||||
|
||||
public static final byte ALTER_SENDER = 1;
|
||||
public static final byte ALTER_SUBJECT = 2;
|
||||
public static final byte ALTER_MSG = 4;
|
||||
public static final byte ALTER_OOB = 8;
|
||||
public static final byte ALTER_SENT_TIME = 16;
|
||||
public static final byte ALTER_CATEGORY = 32;
|
||||
|
||||
}
|
||||
11
src/main/java/chat/util/PersistentMessageStatus.java
Normal file
11
src/main/java/chat/util/PersistentMessageStatus.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package chat.util;
|
||||
|
||||
public class PersistentMessageStatus {
|
||||
|
||||
public static final byte NEW = 1;
|
||||
public static final byte UNREAD = 2;
|
||||
public static final byte READ = 3;
|
||||
public static final byte TRASH = 4;
|
||||
public static final byte DELETED = 5;
|
||||
|
||||
}
|
||||
10
src/main/java/chat/util/SnoopTypes.java
Normal file
10
src/main/java/chat/util/SnoopTypes.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package chat.util;
|
||||
|
||||
public class SnoopTypes {
|
||||
|
||||
public static final byte SNOOP_INSTANTMESSAGE = 0;
|
||||
public static final byte SNOOP_ROOMMESSAGE = 1;
|
||||
public static final byte SNOOP_PERSISTENTMESSAGE = 2;
|
||||
public static final byte SNOOP_END = 3;
|
||||
|
||||
}
|
||||
17
src/main/java/log4j2.xml
Normal file
17
src/main/java/log4j2.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="INFO">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
|
||||
</Console>
|
||||
<File name="MyFile" fileName="all.log" immediateFlush="false" append="false">
|
||||
<PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||
</File>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="debug">
|
||||
<AppenderRef ref="Console" />
|
||||
<AppenderRef ref="MyFile"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
Reference in New Issue
Block a user