Added events that were needed

This commit is contained in:
Manevolent
2018-08-01 12:46:14 -04:00
parent f50ada0888
commit 401f00c83d
5 changed files with 54 additions and 4 deletions
@@ -0,0 +1,45 @@
package com.github.manevolent.ts3j.event;
/*
* #%L
* TeamSpeak 3 Java API
* %%
* Copyright (C) 2014 Bert De Geyter
* %%
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* #L%
*/
import java.util.Map;
public class ClientUpdatedEvent extends BaseEvent {
public ClientUpdatedEvent(Map<String, String> map) {
super(map);
}
public int getClientId() {
return getInt("clid");
}
@Override
public void fire(TS3Listener listener) {
listener.onClientChanged(this);
}
}
@@ -61,8 +61,12 @@ public interface TS3Event {
return new ServerGroupListEvent(command.toMap()); return new ServerGroupListEvent(command.toMap());
case "notifychannelgrouplist": // CLIENT case "notifychannelgrouplist": // CLIENT
return new ChannelGroupListEvent(command.toMap()); return new ChannelGroupListEvent(command.toMap());
case "notifyclientchannelgroupchanged": // CLIENT
return new ClientChannelGroupChangedEvent(command.toMap());
case "notifyclientneededpermissions": // CLIENT case "notifyclientneededpermissions": // CLIENT
return new ClientNeededPermissionsEvent(command.toMap()); return new ClientNeededPermissionsEvent(command.toMap());
case "notifyclientupdated": // CLIENT
return new ClientUpdatedEvent(command.toMap());
default: default:
throw new IllegalArgumentException("unknown event: " + command.getName()); throw new IllegalArgumentException("unknown event: " + command.getName());
} }
@@ -60,4 +60,6 @@ public interface TS3Listener {
void onClientChannelGroupChanged(ClientChannelGroupChangedEvent e); void onClientChannelGroupChanged(ClientChannelGroupChangedEvent e);
void onClientChanged(ClientUpdatedEvent e);
} }
@@ -472,6 +472,8 @@ public abstract class AbstractTeamspeakClientSocket
// Finally, handle compressed bodies // Finally, handle compressed bodies
if (packet.getBody() instanceof PacketBodyCompressed) { if (packet.getBody() instanceof PacketBodyCompressed) {
Ts3Debugging.debug("[PROTOCOL] DECOMPRESS " + networkPacket.getHeader().getType().name());
byte[] decompressed = QuickLZ.decompress(((PacketBodyCompressed) packet.getBody()).getCompressed()); byte[] decompressed = QuickLZ.decompress(((PacketBodyCompressed) packet.getBody()).getCompressed());
packetBuffer = ByteBuffer packetBuffer = ByteBuffer
@@ -481,8 +483,6 @@ public abstract class AbstractTeamspeakClientSocket
packet = new Packet(packet.getRole(), packet.getHeader()); packet = new Packet(packet.getRole(), packet.getHeader());
packet.readBody(packetBuffer); packet.readBody(packetBuffer);
Ts3Debugging.debug("[PROTOCOL] DECOMPRESS " + networkPacket.getHeader().getType().name());
} }
// Return to parent handler // Return to parent handler
@@ -988,7 +988,6 @@ public abstract class AbstractTeamspeakClientSocket
private boolean putRelative(int index, int generation) { private boolean putRelative(int index, int generation) {
Integer existing = buffer[index]; Integer existing = buffer[index];
Ts3Debugging.debug("putRelative: " + index);
if (existing == null || existing != generation) { if (existing == null || existing != generation) {
buffer[index] = generation; buffer[index] = generation;
return true; return true;
@@ -324,7 +324,7 @@ public final class QuickLZ
int level = (source[0] >>> 2) & 0x3; int level = (source[0] >>> 2) & 0x3;
if (level != 1 && level != 3) if (level != 1 && level != 3)
return source; throw new IllegalArgumentException("unsupported QuickLZ level: " + level);
if ((source[0] & 1) != 1) if ((source[0] & 1) != 1)
{ {