Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Commands/Tracker/TrackFlipEventCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using MessagePack;
using Newtonsoft.Json;
using RestSharp;

namespace hypixel
{
public class TrackFlipEventCommand : Command
{
public override async Task Execute(MessageData data)
{
using (var context = new HypixelContext())
{
var args = data.GetAs<Arguments>();
var userId = data.UserId;

var request = new RestRequest("Tracker/flipEvent/{auctionUUID}", Method.POST)
.AddJsonBody(args)
.AddUrlSegment("auctionUUID", args.AuctionUUID);

await data.SendBack(new MessageData("flipEvent", null));
}
}

[MessagePackObject]
public class Arguments
{
[Key("playerUUID")]
public string PlayerUUID;
[Key("auctionUUID")]
public string AuctionUUID;
[Key("flipEventType")]
public FlipEventType FlipTrackerEvent;

}

public enum FlipEventType
{
FLIP_RECEIVE = 1,
FLIP_CLICK = 2,
PURCHASE_START = 4,
PURCHASE_CONFIRM = 8,
AUCTION_SOLD = 16
}
}
}
47 changes: 47 additions & 0 deletions Commands/Tracker/TrackNewFlipCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using MessagePack;
using Newtonsoft.Json;
using RestSharp;

namespace hypixel
{
public class TrackNewFlipCommand : Command
{
public override async Task Execute(MessageData data)
{
using (var context = new HypixelContext())
{
var args = data.GetAs<Arguments>();
var userId = data.UserId;

var request = new RestRequest("Tracker/newFlip/{auctionUUID}", Method.POST)
.AddJsonBody(args)
.AddUrlSegment("auctionUUID", args.AuctionUUID);

await data.SendBack(new MessageData("newFlip", null));
}
}

[MessagePackObject]
public class Arguments
{
[Key("auctionUUID")]
public string AuctionUUID;
[Key("targetPrice")]
public int TargetPrice;
[Key("finderType")]
public FinderType FinderType;

}

public enum FinderType
{
FLIPPER = 1,
LOWEST_BIN = 2,
SNIPER = 4,
KI = 8
}
}
}
14 changes: 14 additions & 0 deletions Commands/Tracker/TrackerClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json;
using RestSharp;

namespace hypixel
{
public static class TrackerClient
{
public static RestClient Client = new RestClient("http://" + SimplerConfig.Config.Instance["TRACKER_HOST"]);

}
}
3 changes: 2 additions & 1 deletion Socket/SkyblockBackEnd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ static SkyblockBackEnd()
Commands.Add("newAuctions", new NewAuctionsCommand());
Commands.Add("p", new PingCommand());


Commands.Add("trackNewFlip", new TrackNewFlipCommand());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would the frontend need this command?

Commands.Add("trackFlipEvent", new TrackFlipEventCommand());

}

Expand Down