Skip to content

Commit

Permalink
Merge pull request #190 from LossyDragon/fix_sample_2
Browse files Browse the repository at this point in the history
Re-enable Sample 2 due to a missing dependency.
  • Loading branch information
LossyDragon authored Jan 18, 2022
2 parents 242936a + a2728e3 commit 41ec209
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 13 deletions.
4 changes: 4 additions & 0 deletions javasteam-samples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -21,17 +29,16 @@ public EResult getResult() {
}
}

*//**
/**
* JavaSteam edit:
* <p>
* 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<CMsgClientLogOff.Builder> logOffMessage = new ClientMsgProtobuf<>(CMsgClientLogOff.class, EMsg.ClientLogOff);
// client.send(logOffMessage);
ClientMsgProtobuf<CMsgClientLogOff.Builder> logOffMessage = new ClientMsgProtobuf<>(CMsgClientLogOff.class, EMsg.ClientLogOff);
client.send(logOffMessage);

client.disconnect(); // JavaSteam edit here.
}
Expand Down Expand Up @@ -74,5 +81,5 @@ private void handleLogonResponse(IPacketMsg packetMsg) {

// post the callback to be consumed by user code
client.postCallback(new MyCallback(result));
}*/
}
}
}
Original file line number Diff line number Diff line change
@@ -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
//
Expand All @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -150,5 +162,5 @@ private void onMyCallback(MyHandler.MyCallback callback) {

// for this sample we'll just log off
myHandler.logOff("", "");
}*/
}
}

0 comments on commit 41ec209

Please sign in to comment.