Skip to content

Commit

Permalink
Merge pull request NecronomiconCoding#1558 from TheTravelingTrainer/m…
Browse files Browse the repository at this point in the history
…aster

Fixes files missing from cproj. Also adds callback helper id for web requests
  • Loading branch information
NecronomiconCoding authored Jul 31, 2016
2 parents 3885180 + b0c8965 commit 5c47bfc
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 12 deletions.
7 changes: 7 additions & 0 deletions PoGo.NecroBot.CLI/PoGo.NecroBot.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@
<Compile Include="SimpleSession.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WebSocketHandler\BasicGetCommands\Events\EggListResponce.cs" />
<Compile Include="WebSocketHandler\BasicGetCommands\Events\ItemListResponce.cs" />
<Compile Include="WebSocketHandler\BasicGetCommands\GetEggListHandler.cs" />
<Compile Include="WebSocketHandler\BasicGetCommands\GetItemsListHandler.cs" />
<Compile Include="WebSocketHandler\BasicGetCommands\Helpers\EggListWeb.cs" />
<Compile Include="WebSocketHandler\BasicGetCommands\Tasks\GetEggListTask.cs" />
<Compile Include="WebSocketHandler\BasicGetCommands\Tasks\GetItemListTask.cs" />
<Compile Include="WebSocketHandler\EncodingHelper.cs" />
<Compile Include="WebSocketHandler\IWebSocketResponce.cs" />
<Compile Include="WebSocketHandler\IWebSocketRequestHandler.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ namespace PoGo.NecroBot.CLI.WebSocketHandler.BasicGetCommands.Events
{
public class EggListResponce : IWebSocketResponce
{
public EggListResponce(dynamic data)
public EggListResponce(dynamic data, string requestID)
{
Command = "EggListWeb";
Data = data;
RequestID = requestID;
}
public string RequestID { get; private set; }
public string Command { get; private set; }
public dynamic Data { get; private set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ namespace PoGo.NecroBot.CLI.WebSocketHandler.BasicGetCommands.Events
{
class ItemListResponce : IWebSocketResponce
{
public ItemListResponce(dynamic data)
public ItemListResponce(dynamic data,string requestID)
{
Command = "ItemListWeb";
Data = data;
RequestID = requestID;
}
public string RequestID { get; private set; }
public string Command { get; private set; }
public dynamic Data { get; private set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ namespace PoGo.NecroBot.CLI.WebSocketHandler.BasicGetCommands.Events
{
public class PokemonListResponce : IWebSocketResponce, IEvent
{
public PokemonListResponce(dynamic data)
public PokemonListResponce(dynamic data, string requestID)
{
Command = "PokemonListWeb";
Data = data;
RequestID = requestID;
}
public string RequestID { get; private set; }
public string Command { get; private set; }
public dynamic Data { get; private set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public GetEggListHandler()

public async Task Handle(ISession session, WebSocketSession webSocketSession, dynamic message)
{
await GetEggListTask.Execute(session, webSocketSession);
await GetEggListTask.Execute(session, webSocketSession, (string)message.RequestID);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public GetItemsListHandler()

public async Task Handle(ISession session, WebSocketSession webSocketSession, dynamic message)
{
await GetItemListTask.Execute(session, webSocketSession);
await GetItemListTask.Execute(session, webSocketSession, message.requestID);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public GetPokemonListHandler()

public async Task Handle(ISession session, WebSocketSession webSocketSession, dynamic message)
{
await GetPokemonListTask.Execute(session, webSocketSession);
await GetPokemonListTask.Execute(session, webSocketSession, (string)message.RequestID);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace PoGo.NecroBot.CLI.WebSocketHandler.BasicGetCommands.Tasks
class GetEggListTask
{

public static async Task Execute(ISession session, WebSocketSession webSocketSession)
public static async Task Execute(ISession session, WebSocketSession webSocketSession, string requestID)
{
var incubators = (await session.Inventory.GetEggIncubators())
.Where(x => x.UsesRemaining > 0 || x.ItemId == ItemId.ItemIncubatorBasicUnlimited)
Expand All @@ -32,7 +32,7 @@ public static async Task Execute(ISession session, WebSocketSession webSocketSes
Incubators = incubators,
UnusedEggs = unusedEggs
};
webSocketSession.Send(EncodingHelper.Serialize(new EggListResponce(list)));
webSocketSession.Send(EncodingHelper.Serialize(new EggListResponce(list,requestID)));

await Task.Delay(500);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace PoGo.NecroBot.CLI.WebSocketHandler.BasicGetCommands.Tasks
{
class GetItemListTask
{
public static async Task Execute(ISession session, WebSocketSession webSocketSession)
public static async Task Execute(ISession session, WebSocketSession webSocketSession, string requestID)
{
var allItems = await session.Inventory.GetItems();
webSocketSession.Send(EncodingHelper.Serialize(new ItemListResponce(allItems)));
webSocketSession.Send(EncodingHelper.Serialize(new ItemListResponce(allItems, requestID)));
await Task.Delay(500);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ namespace PoGo.NecroBot.CLI.WebSocketHandler.BasicGetCommands.Tasks
class GetPokemonListTask
{

public static async Task Execute(ISession session, WebSocketSession webSocketSession)
public static async Task Execute(ISession session, WebSocketSession webSocketSession, string requestID)
{
var allPokemonInBag = await session.Inventory.GetHighestsCp(1000);
var list = new List<PokemonListWeb>();
allPokemonInBag.ToList().ForEach(o => list.Add(new PokemonListWeb(o)));
webSocketSession.Send(EncodingHelper.Serialize(new PokemonListResponce(list)));
webSocketSession.Send(EncodingHelper.Serialize(new PokemonListResponce(list,requestID)));

await Task.Delay(500);
}
Expand Down
1 change: 1 addition & 0 deletions PoGo.NecroBot.CLI/WebSocketHandler/IWebSocketResponce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace PoGo.NecroBot.CLI.WebSocketHandler
{
interface IWebSocketResponce
{
string RequestID { get; }
string Command { get; }
dynamic Data { get; }
}
Expand Down

0 comments on commit 5c47bfc

Please sign in to comment.