diff --git a/javasteam-samples/build.gradle b/javasteam-samples/build.gradle
index d8378c33..a096b17a 100644
--- a/javasteam-samples/build.gradle
+++ b/javasteam-samples/build.gradle
@@ -12,5 +12,9 @@ repositories {
dependencies {
compile rootProject
implementation 'org.bouncycastle:bcprov-jdk15on:1.69'
+
+ // To access protobufs directly. As shown in Sample #2
+ implementation 'com.google.protobuf:protobuf-java:3.17.3'
+
testCompile group: 'junit', name: 'junit', version: '4.13.2'
}
diff --git a/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_2extending/MyHandler.java b/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_2extending/MyHandler.java
index b658b5bf..fff1ee89 100644
--- a/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_2extending/MyHandler.java
+++ b/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_2extending/MyHandler.java
@@ -1,10 +1,18 @@
package in.dragonbra.javasteamsamples._2extending;
+import in.dragonbra.javasteam.base.ClientMsgProtobuf;
+import in.dragonbra.javasteam.base.IPacketMsg;
+import in.dragonbra.javasteam.enums.EMsg;
+import in.dragonbra.javasteam.enums.EResult;
+import in.dragonbra.javasteam.handlers.ClientMsgHandler;
+import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserverLogin.CMsgClientLogOff;
+import in.dragonbra.javasteam.protobufs.steamclient.SteammessagesClientserverLogin.CMsgClientLogonResponse;
import in.dragonbra.javasteam.steam.handlers.steamuser.SteamUser;
+import in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackMsg;
-public class MyHandler /*extends ClientMsgHandler*/ {
+public class MyHandler extends ClientMsgHandler {
- /*// define our custom callback class
+ // define our custom callback class
// this will pass data back to the user of the handler
static class MyCallback extends CallbackMsg {
@@ -21,17 +29,16 @@ public EResult getResult() {
}
}
- *//**
+ /**
* JavaSteam edit:
*
* There is a log-off bug currently. Check the to-do at {@link SteamUser#logOff()}
* The concept of this example is still valid.
- *//*
+ */
// handlers can also define functions which can send data to the steam servers
public void logOff(String user, String pass) {
-
-// ClientMsgProtobuf logOffMessage = new ClientMsgProtobuf<>(CMsgClientLogOff.class, EMsg.ClientLogOff);
-// client.send(logOffMessage);
+ ClientMsgProtobuf logOffMessage = new ClientMsgProtobuf<>(CMsgClientLogOff.class, EMsg.ClientLogOff);
+ client.send(logOffMessage);
client.disconnect(); // JavaSteam edit here.
}
@@ -74,5 +81,5 @@ private void handleLogonResponse(IPacketMsg packetMsg) {
// post the callback to be consumed by user code
client.postCallback(new MyCallback(result));
- }*/
-}
+ }
+}
\ No newline at end of file
diff --git a/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_2extending/SampleExtending.java b/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_2extending/SampleExtending.java
index d71ba340..e4bb4f41 100644
--- a/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_2extending/SampleExtending.java
+++ b/javasteam-samples/src/main/java/in/dragonbra/javasteamsamples/_2extending/SampleExtending.java
@@ -1,5 +1,17 @@
package in.dragonbra.javasteamsamples._2extending;
+import in.dragonbra.javasteam.enums.EResult;
+import in.dragonbra.javasteam.steam.handlers.steamuser.LogOnDetails;
+import in.dragonbra.javasteam.steam.handlers.steamuser.SteamUser;
+import in.dragonbra.javasteam.steam.handlers.steamuser.callback.LoggedOffCallback;
+import in.dragonbra.javasteam.steam.handlers.steamuser.callback.LoggedOnCallback;
+import in.dragonbra.javasteam.steam.steamclient.SteamClient;
+import in.dragonbra.javasteam.steam.steamclient.callbackmgr.CallbackManager;
+import in.dragonbra.javasteam.steam.steamclient.callbacks.ConnectedCallback;
+import in.dragonbra.javasteam.steam.steamclient.callbacks.DisconnectedCallback;
+import in.dragonbra.javasteam.util.log.DefaultLogListener;
+import in.dragonbra.javasteam.util.log.LogManager;
+
//
// Sample 2: Extending SteamKit2
//
@@ -16,9 +28,9 @@
* @since 2021-10-11
*/
@SuppressWarnings("Duplicates")
-public class SampleExtending/* implements Runnable*/ {
+public class SampleExtending implements Runnable {
- /*private SteamClient steamClient;
+ private SteamClient steamClient;
private CallbackManager manager;
@@ -45,7 +57,7 @@ public static void main(String[] args) {
LogManager.addListener(new DefaultLogListener());
- // new SampleExtending(args[0], args[1]).run();
+ new SampleExtending(args[0], args[1]).run();
}
@Override
@@ -150,5 +162,5 @@ private void onMyCallback(MyHandler.MyCallback callback) {
// for this sample we'll just log off
myHandler.logOff("", "");
- }*/
+ }
}