We don't have an "onConnected" event, adding that now.
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
package com.github.manevolent.ts3j.event;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ConnectedEvent extends BaseEvent {
|
||||||
|
public ConnectedEvent(Map<String, String> map) {
|
||||||
|
super(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fire(TS3Listener listener) {
|
||||||
|
listener.onConnected(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,4 +53,5 @@ public interface TS3Listener {
|
|||||||
default void onClientPoke(ClientPokeEvent e) {}
|
default void onClientPoke(ClientPokeEvent e) {}
|
||||||
default void onClientComposing(ClientChatComposingEvent e) {}
|
default void onClientComposing(ClientChatComposingEvent e) {}
|
||||||
default void onPermissionList(PermissionListEvent e) {}
|
default void onPermissionList(PermissionListEvent e) {}
|
||||||
|
default void onConnected(ConnectedEvent e) {}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -2,8 +2,16 @@ package com.github.manevolent.ts3j.protocol.packet.handler.client;
|
|||||||
|
|
||||||
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
public class LocalClientHandlerConnected extends LocalClientHandlerFull {
|
public class LocalClientHandlerConnected extends LocalClientHandlerFull {
|
||||||
public LocalClientHandlerConnected(LocalTeamspeakClientSocket client) {
|
public LocalClientHandlerConnected(LocalTeamspeakClientSocket client) {
|
||||||
super(client);
|
super(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAssigned() throws IOException, TimeoutException {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -188,6 +188,8 @@ public abstract class AbstractTeamspeakClientSocket
|
|||||||
|
|
||||||
if (state == ClientConnectionState.DISCONNECTED && !initialState)
|
if (state == ClientConnectionState.DISCONNECTED && !initialState)
|
||||||
onDisconnect();
|
onDisconnect();
|
||||||
|
else if (state == ClientConnectionState.CONNECTED && !initialState)
|
||||||
|
onConnect();
|
||||||
|
|
||||||
Ts3Debugging.debug("State changed: " + state.name());
|
Ts3Debugging.debug("State changed: " + state.name());
|
||||||
}
|
}
|
||||||
@@ -214,6 +216,10 @@ public abstract class AbstractTeamspeakClientSocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onConnect() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected void onDisconnect() {
|
protected void onDisconnect() {
|
||||||
clientId = -1;
|
clientId = -1;
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -70,8 +70,8 @@ public class LocalTeamspeakClientSocket
|
|||||||
@Override
|
@Override
|
||||||
public void process(AbstractTeamspeakClientSocket client, SingleCommand singleCommand)
|
public void process(AbstractTeamspeakClientSocket client, SingleCommand singleCommand)
|
||||||
throws CommandProcessException {
|
throws CommandProcessException {
|
||||||
ChannelListEvent channelListEvent = new ChannelListEvent(singleCommand.toMap());
|
final ChannelListEvent channelListEvent = new ChannelListEvent(singleCommand.toMap());
|
||||||
for (TS3Listener listener : listeners) listener.onChannelList(channelListEvent);
|
commandExecutionService.submit(() -> listeners.forEach(e -> e.onChannelList(channelListEvent)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -273,6 +273,14 @@ public class LocalTeamspeakClientSocket
|
|||||||
super.setIdentity(identity);
|
super.setIdentity(identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onConnect() {
|
||||||
|
super.onConnect();
|
||||||
|
|
||||||
|
final ConnectedEvent connectedEvent = new ConnectedEvent(Collections.emptyMap());
|
||||||
|
commandExecutionService.submit(() -> listeners.forEach(e -> e.onConnected(connectedEvent)));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDisconnect() {
|
protected void onDisconnect() {
|
||||||
super.onDisconnect();
|
super.onDisconnect();
|
||||||
|
|||||||
Reference in New Issue
Block a user