use of com.google.gson.reflect.TypeToken in project Applozic-Android-SDK by AppLozic.
the class ChannelClientService method createMultipleChannels.
public List<ChannelFeed> createMultipleChannels(List<ChannelInfo> channels) {
List<ChannelFeed> channelFeeds = null;
try {
String jsonFromObject = GsonUtils.getJsonFromObject(channels, new TypeToken<List<ChannelInfo>>() {
}.getType());
String createChannelResponse = httpRequestUtils.postData(getCreateMultipleChannelUrl(), "application/json", "application/json", jsonFromObject);
Utils.printLog(context, TAG, "Create Multiple channel Response :" + createChannelResponse);
MultipleChannelFeedApiResponse channelFeedApiResponse = (MultipleChannelFeedApiResponse) GsonUtils.getObjectFromJson(createChannelResponse, MultipleChannelFeedApiResponse.class);
if (channelFeedApiResponse != null && channelFeedApiResponse.isSuccess()) {
channelFeeds = channelFeedApiResponse.getResponse();
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
return channelFeeds;
}
use of com.google.gson.reflect.TypeToken in project CloudNet by Dytanic.
the class PacketInUpdateServerGroup method handleInput.
@Override
public void handleInput(Document data, PacketSender packetSender) {
ServerGroup proxyGroup = data.getObject("group", new TypeToken<ServerGroup>() {
}.getType());
CloudNet.getInstance().getConfig().createGroup(proxyGroup);
try {
CloudNet.getInstance().getConfig().load();
} catch (Exception e) {
e.printStackTrace();
}
CloudNet.getInstance().getServerGroups().clear();
CloudNet.getInstance().getProxyGroups().clear();
NetworkUtils.addAll(CloudNet.getInstance().getServerGroups(), CloudNet.getInstance().getConfig().getServerGroups(), new Acceptable<ServerGroup>() {
@Override
public boolean isAccepted(ServerGroup value) {
System.out.println("Loading server group: " + value.getName());
return true;
}
});
NetworkUtils.addAll(CloudNet.getInstance().getProxyGroups(), CloudNet.getInstance().getConfig().getProxyGroups(), new Acceptable<ProxyGroup>() {
@Override
public boolean isAccepted(ProxyGroup value) {
System.out.println("Loading proxy group: " + value.getName());
return true;
}
});
CloudNet.getInstance().getNetworkManager().reload();
CloudNet.getInstance().getNetworkManager().updateAll0();
CloudNet.getInstance().getWrappers().values().forEach(new Consumer<Wrapper>() {
@Override
public void accept(Wrapper wrapper) {
wrapper.updateWrapper();
}
});
}
use of com.google.gson.reflect.TypeToken in project CloudNet by Dytanic.
the class PacketInServerDispatchCommand method handleInput.
@Override
public void handleInput(Document data, PacketSender packetSender) {
DefaultType defaultType = data.getObject("defaultType", new TypeToken<DefaultType>() {
}.getType());
String serverId = data.getString("serverId");
String commandLine = data.getString("commandLine");
if (defaultType == DefaultType.BUKKIT) {
MinecraftServer minecraftServer = CloudNet.getInstance().getServer(serverId);
if (minecraftServer != null) {
minecraftServer.getWrapper().writeServerCommand(commandLine, minecraftServer.getServerInfo());
}
CloudServer cloudServer = CloudNet.getInstance().getCloudGameServer(serverId);
if (cloudServer != null) {
cloudServer.getWrapper().writeServerCommand(commandLine, minecraftServer.getServerInfo());
}
} else {
ProxyServer proxyServer = CloudNet.getInstance().getProxy(serverId);
if (proxyServer != null) {
proxyServer.getWrapper().writeProxyCommand(commandLine, proxyServer.getProxyInfo());
}
}
}
use of com.google.gson.reflect.TypeToken in project CloudNet by Dytanic.
the class PacketAPIInNameUUID method handleInput.
@Override
public void handleInput(Document data, PacketSender packetSender) {
if (data.contains("uniqueId")) {
UUID uniqueId = data.getObject("uniqueId", new TypeToken<UUID>() {
}.getType());
String name = CloudNet.getInstance().getDbHandlers().getNameToUUIDDatabase().get(uniqueId);
packetSender.sendPacket(getResult(new Document("name", name)));
} else {
String name = data.getString("name");
UUID uniqueId = CloudNet.getInstance().getDbHandlers().getNameToUUIDDatabase().get(name);
packetSender.sendPacket(getResult(new Document("uniqueId", uniqueId)));
}
}
use of com.google.gson.reflect.TypeToken in project CloudNet by Dytanic.
the class PacketInUpdatePlayer method handleInput.
@Override
public void handleInput(Document data, PacketSender packetSender) {
OfflinePlayer offlinePlayer = data.getObject("player", new TypeToken<OfflinePlayer>() {
}.getType());
CloudNet.getInstance().getDbHandlers().getPlayerDatabase().updatePlayer(offlinePlayer);
if (CloudNet.getInstance().getNetworkManager().getOnlinePlayers().containsKey(offlinePlayer.getUniqueId())) {
CloudPlayer cloudPlayer = CloudNet.getInstance().getNetworkManager().getOnlinePlayers().get(offlinePlayer.getUniqueId());
cloudPlayer.setMetaData(offlinePlayer.getMetaData());
cloudPlayer.setPermissionEntity(offlinePlayer.getPermissionEntity());
CloudNet.getInstance().getNetworkManager().handlePlayerUpdate(cloudPlayer);
} else
CloudNet.getInstance().getNetworkManager().sendAllUpdate(new PacketOutUpdateOfflinePlayer(offlinePlayer));
}
Aggregations