-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
109 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,5 +24,6 @@ public enum EventType | |
|
||
DynamicEvent, | ||
FateWatchListChanged, | ||
Queue, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) FFCafe. All rights reserved. | ||
// Licensed under the AGPL-3.0 license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Cafe.Matcha.DTO | ||
{ | ||
using Cafe.Matcha.Constant; | ||
using Newtonsoft.Json; | ||
|
||
internal class QueueDTO : BaseDTO | ||
{ | ||
public override EventType EventType | ||
{ | ||
get | ||
{ | ||
return EventType.Queue; | ||
} | ||
} | ||
|
||
[JsonProperty("type")] | ||
public string Type; | ||
|
||
[JsonProperty("stage")] | ||
public string Stage; | ||
|
||
[JsonProperty("order")] | ||
public uint Order = 0; | ||
|
||
[JsonProperty("time")] | ||
public uint Time = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) FFCafe. All rights reserved. | ||
// Licensed under the AGPL-3.0 license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Cafe.Matcha.Network.Handler | ||
{ | ||
using System; | ||
using Cafe.Matcha.Constant; | ||
using Cafe.Matcha.DTO; | ||
using Cafe.Matcha.Network.Structures; | ||
|
||
internal class QueueHandler : AbstractHandler | ||
{ | ||
public QueueHandler(Action<BaseDTO> fireEvent) : base(fireEvent) | ||
{ | ||
} | ||
|
||
public override bool Handle(Packet packet) | ||
{ | ||
if (packet.MatchaOpcode == MatchaOpcode.WorldVisitQueue) | ||
{ | ||
var data = WorldVisitQueue.Read(packet.GetRawData()); | ||
fireEvent(new QueueDTO() | ||
{ | ||
Type = "world-visit", | ||
Stage = data.Stage == 1 ? "waiting" : data.Stage == 2 ? "ready" : data.Stage == 3 ? "done" : "unknown", | ||
Order = data.Order, | ||
Time = data.Time, | ||
}); | ||
|
||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) FFCafe. All rights reserved. | ||
// Licensed under the AGPL-3.0 license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Cafe.Matcha.Network.Structures | ||
{ | ||
using System.IO; | ||
|
||
public class WorldVisitQueue | ||
{ | ||
public uint Stage { get; internal set; } | ||
public uint Order { get; internal set; } | ||
public uint Time { get; internal set; } | ||
|
||
/// <summary> | ||
/// Read a <see cref="WorldVisitQueue"/> object from memory. | ||
/// </summary> | ||
/// <param name="data">Data to read.</param> | ||
/// <returns>A new <see cref="WorldVisitQueue"/> object.</returns> | ||
public static WorldVisitQueue Read(byte[] data) | ||
{ | ||
using (var stream = new MemoryStream(data)) | ||
{ | ||
using (var reader = new BinaryReader(stream)) | ||
{ | ||
var output = new WorldVisitQueue(); | ||
output.Stage = reader.ReadUInt32(); | ||
output.Order = reader.ReadUInt32(); | ||
output.Time = reader.ReadUInt32(); | ||
return output; | ||
} | ||
} | ||
} | ||
} | ||
} |