mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-13 15:34:36 +01:00
implement a few more messages
This commit is contained in:
@@ -32,6 +32,15 @@ namespace nksrv.LobbyServer
|
||||
public async Task HandleAsync(IHttpContext ctx)
|
||||
{
|
||||
this.ctx = ctx;
|
||||
if (ctx.Request.Headers.AllKeys.Contains("Authorization"))
|
||||
{
|
||||
var token = ctx.Request.Headers["Authorization"];
|
||||
if (token != null)
|
||||
{
|
||||
UsedAuthToken = token;
|
||||
}
|
||||
}
|
||||
|
||||
await HandleAsync();
|
||||
}
|
||||
public async Task HandleAsync(string authToken)
|
||||
|
||||
23
nksrv/LobbyServer/Msgs/Auth/AuthLogout.cs
Normal file
23
nksrv/LobbyServer/Msgs/Auth/AuthLogout.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Google.Protobuf;
|
||||
using nksrv.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace nksrv.LobbyServer.Msgs.Auth
|
||||
{
|
||||
[PacketPath("/auth/logout")]
|
||||
public class AuthLogout : LobbyMsgHandler
|
||||
{
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
var req = await ReadData<ReqLogout>();
|
||||
|
||||
|
||||
WriteData(new ResLogout());
|
||||
}
|
||||
}
|
||||
}
|
||||
24
nksrv/LobbyServer/Msgs/Character/GetCharacterCostume.cs
Normal file
24
nksrv/LobbyServer/Msgs/Character/GetCharacterCostume.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using nksrv.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace nksrv.LobbyServer.Msgs.Character
|
||||
{
|
||||
[PacketPath("/character/costume/get")]
|
||||
public class GetCharacterCostume : LobbyMsgHandler
|
||||
{
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
var req = ReadData<ReqGetCharacterCostumeData>();
|
||||
|
||||
var response = new ResGetCharacterCostumeData();
|
||||
|
||||
// TODO implement
|
||||
|
||||
WriteData(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
nksrv/LobbyServer/Msgs/Event/GetJoinedEvent.cs
Normal file
24
nksrv/LobbyServer/Msgs/Event/GetJoinedEvent.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using nksrv.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace nksrv.LobbyServer.Msgs.Event
|
||||
{
|
||||
[PacketPath("/event/getjoinedevent")]
|
||||
public class EnterLobbyPing : LobbyMsgHandler
|
||||
{
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
var req = await ReadData<ReqGetJoinedEvent>();
|
||||
|
||||
var response = new ResGetJoinedEvent();
|
||||
|
||||
// TODO
|
||||
|
||||
WriteData(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
nksrv/LobbyServer/Msgs/Event/ListEvents.cs
Normal file
24
nksrv/LobbyServer/Msgs/Event/ListEvents.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using nksrv.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace nksrv.LobbyServer.Msgs.Event
|
||||
{
|
||||
[PacketPath("/event/list")]
|
||||
public class ListEvents : LobbyMsgHandler
|
||||
{
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
var req = await ReadData<ReqGetEventList>();
|
||||
|
||||
var response = new ResGetEventList();
|
||||
|
||||
// TODO: Support events
|
||||
|
||||
WriteData(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
17
nksrv/LobbyServer/Msgs/Misc/EnterLobbyPing.cs
Normal file
17
nksrv/LobbyServer/Msgs/Misc/EnterLobbyPing.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using nksrv.Utils;
|
||||
|
||||
namespace nksrv.LobbyServer.Msgs.Misc
|
||||
{
|
||||
[PacketPath("/enterlobbyping")]
|
||||
public class EnterLobbyPing : LobbyMsgHandler
|
||||
{
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
var req = await ReadData<ReqEnterLobbyPing>();
|
||||
|
||||
var response = new ResEnterLobbyPing();
|
||||
|
||||
WriteData(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
23
nksrv/LobbyServer/Msgs/Mission/Rewards/GetDailyRewards.cs
Normal file
23
nksrv/LobbyServer/Msgs/Mission/Rewards/GetDailyRewards.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using nksrv.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace nksrv.LobbyServer.Msgs.Mission.Rewards
|
||||
{
|
||||
[PacketPath("/mission/getrewarded/daily")]
|
||||
public class GetDailyRewards : LobbyMsgHandler
|
||||
{
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
var req = ReadData<ReqGetDailyRewardedData>();
|
||||
|
||||
// TODO: implement
|
||||
var response = new ResGetDailyRewardedData();
|
||||
|
||||
WriteData(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
23
nksrv/LobbyServer/Msgs/Mission/Rewards/GetWeeklyRewards.cs
Normal file
23
nksrv/LobbyServer/Msgs/Mission/Rewards/GetWeeklyRewards.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using nksrv.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace nksrv.LobbyServer.Msgs.Mission.Rewards
|
||||
{
|
||||
[PacketPath("/mission/getrewarded/weekly")]
|
||||
public class GetWeeklyRewards : LobbyMsgHandler
|
||||
{
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
var req = ReadData<ReqGetWeeklyRewardedData>();
|
||||
|
||||
// TODO: implement
|
||||
var response = new ResGetWeeklyRewardedData();
|
||||
|
||||
WriteData(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
nksrv/LobbyServer/Msgs/Pass/GetActiveEventPassData.cs
Normal file
24
nksrv/LobbyServer/Msgs/Pass/GetActiveEventPassData.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using nksrv.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace nksrv.LobbyServer.Msgs.Pass
|
||||
{
|
||||
[PacketPath("/pass/event/getactive")]
|
||||
public class GetActiveEventPassData : LobbyMsgHandler
|
||||
{
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
var req = await ReadData<ReqGetActiveEventPassData>();
|
||||
|
||||
var response = new ResGetActiveEventPassData();
|
||||
|
||||
// TODO: Support events
|
||||
|
||||
WriteData(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
nksrv/LobbyServer/Msgs/Pass/GetActivePassData.cs
Normal file
24
nksrv/LobbyServer/Msgs/Pass/GetActivePassData.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using nksrv.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace nksrv.LobbyServer.Msgs.Pass
|
||||
{
|
||||
[PacketPath("/pass/getactive")]
|
||||
public class GetActivePassData : LobbyMsgHandler
|
||||
{
|
||||
protected override async Task HandleAsync()
|
||||
{
|
||||
var req = await ReadData<ReqGetActivePassData>();
|
||||
|
||||
var response = new ResGetActivePassData();
|
||||
|
||||
// TODO: Support events
|
||||
|
||||
WriteData(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using nksrv.Utils;
|
||||
using Swan.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -30,11 +31,28 @@ namespace nksrv.LobbyServer.Msgs.Stage
|
||||
}
|
||||
|
||||
// TODO: figure out how stageid corresponds to chapter
|
||||
user.FieldInfo[0].CompletedStages.Add(new NetFieldStageData() { StageId = req.StageId });
|
||||
user.FieldInfo[GetChapterForStageId(req.StageId)].CompletedStages.Add(new NetFieldStageData() { StageId = req.StageId });
|
||||
JsonDb.Save();
|
||||
}
|
||||
|
||||
WriteData(response);
|
||||
}
|
||||
|
||||
public static int GetChapterForStageId(int stageId)
|
||||
{
|
||||
if (6000001 <= stageId && stageId <= 6000003)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (6001001 <= stageId && stageId <= 6001004)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Error("Unknown stage id: " + stageId);
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,15 +92,27 @@ namespace nksrv
|
||||
var bin = await item.ReadAsByteArrayAsync();
|
||||
var res = await SendReqLocalAndReadResponseAsync(bin);
|
||||
|
||||
List<byte> ResponseWithBytes =
|
||||
[
|
||||
.. Encoding.UTF8.GetBytes("HTTP/1.1 200 OK\r\n"),
|
||||
if (res != null)
|
||||
{
|
||||
List<byte> ResponseWithBytes =
|
||||
[
|
||||
.. Encoding.UTF8.GetBytes("HTTP/1.1 200 OK\r\n"),
|
||||
.. Encoding.UTF8.GetBytes($"Content-Type: application/octet-stream+protobuf\r\n"),
|
||||
.. Encoding.UTF8.GetBytes($"Content-Length: {res.Length}\r\n"),
|
||||
.. Encoding.UTF8.GetBytes($"\r\n"),
|
||||
.. res,
|
||||
];
|
||||
response.AddRange(ResponseWithBytes.ToArray());
|
||||
response.AddRange(ResponseWithBytes.ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
List<byte> ResponseWithBytes =
|
||||
[ .. Encoding.UTF8.GetBytes("HTTP/1.1 404 Not Found\r\n"),
|
||||
//.. Encoding.UTF8.GetBytes($"Content-Type: application/octet-stream+protobuf\r\n"),
|
||||
.. Encoding.UTF8.GetBytes($"Content-Length: 0\r\n"),
|
||||
.. Encoding.UTF8.GetBytes($"\r\n"),
|
||||
];
|
||||
}
|
||||
|
||||
// add boundary, also include http newline if there is binary content
|
||||
|
||||
@@ -122,7 +134,7 @@ namespace nksrv
|
||||
|
||||
return (pieces[0].Trim(), pieces[1].Trim());
|
||||
}
|
||||
private static async Task<byte[]> SendReqLocalAndReadResponseAsync(byte[] bytes)
|
||||
private static async Task<byte[]?> SendReqLocalAndReadResponseAsync(byte[] bytes)
|
||||
{
|
||||
int line = 0;
|
||||
var bodyStartStr = Encoding.UTF8.GetString(bytes);
|
||||
@@ -183,7 +195,7 @@ namespace nksrv
|
||||
url = url.Replace("/v1", "");
|
||||
|
||||
// find appropriate handler
|
||||
Console.WriteLine("BATCH: /v1" + url);
|
||||
Logger.Info("BATCH: /v1" + url);
|
||||
|
||||
foreach (var item in LobbyHandler.Handlers)
|
||||
{
|
||||
@@ -195,8 +207,8 @@ namespace nksrv
|
||||
return item.Value.ReturnBytes;
|
||||
}
|
||||
}
|
||||
Console.WriteLine("HANDLER NOT FOUND: " + url);
|
||||
throw new Exception("handler not found: " + url);
|
||||
Logger.Error("HANDLER NOT FOUND: " + url);
|
||||
return null;
|
||||
}
|
||||
|
||||
private static byte[] ReadStream(Stream stream)
|
||||
|
||||
@@ -1063,3 +1063,84 @@ enum CurrencyType {
|
||||
SimulationRoomPoint = 13000;
|
||||
CharacterSkillReset_Ticket = 14000;
|
||||
}
|
||||
|
||||
message NetEventData {
|
||||
int32 id = 1;
|
||||
int32 eventSystemType = 2;
|
||||
int64 eventStartDate = 4;
|
||||
int64 eventEndDate = 5;
|
||||
int64 eventVisibleDate = 6;
|
||||
int64 eventDisableDate = 7;
|
||||
google.protobuf.Timestamp upcomingEventVisibleDate = 8;
|
||||
}
|
||||
|
||||
message ReqGetEventList {
|
||||
|
||||
}
|
||||
|
||||
message ResGetEventList {
|
||||
repeated NetEventData eventList = 2;
|
||||
}
|
||||
|
||||
message NetEventWithJoinData {
|
||||
NetEventData eventData = 1;
|
||||
int64 joinAt = 2;
|
||||
}
|
||||
|
||||
message ReqEnterLobbyPing {}
|
||||
message ResEnterLobbyPing {}
|
||||
|
||||
message ReqGetJoinedEvent {}
|
||||
message ResGetJoinedEvent {
|
||||
repeated NetEventWithJoinData eventWithJoinData = 3;
|
||||
}
|
||||
|
||||
message ReqGetWeeklyRewardedData {}
|
||||
|
||||
message ResGetWeeklyRewardedData {
|
||||
repeated int32 ids = 2;
|
||||
}
|
||||
|
||||
message ReqGetDailyRewardedData {}
|
||||
message ResGetDailyRewardedData {
|
||||
repeated NetEventWithJoinData eventWithJoinData = 3;
|
||||
}
|
||||
|
||||
message NetPassRankData {
|
||||
int32 passRank = 1;
|
||||
bool isNormalRewarded = 2;
|
||||
bool isPremiumRewarded = 3;
|
||||
}
|
||||
|
||||
message NetPassMissionData {
|
||||
int32 passMissionId = 1;
|
||||
bool isComplete = 2;
|
||||
}
|
||||
|
||||
message NetPassInfo {
|
||||
int32 passId = 1;
|
||||
int32 passPoint = 2;
|
||||
repeated NetPassRankData passRankList = 3;
|
||||
repeated NetPassMissionData passMissionList = 4;
|
||||
int32 passSkipCount = 6;
|
||||
bool premiumActive = 7;
|
||||
}
|
||||
|
||||
message ReqGetActivePassData {
|
||||
|
||||
}
|
||||
|
||||
message ResGetActivePassData {
|
||||
NetPassInfo pass = 1;
|
||||
bool passExist = 2;
|
||||
}
|
||||
|
||||
message ReqGetActiveEventPassData {}
|
||||
message ResGetActiveEventPassData {
|
||||
repeated NetPassInfo passList = 1;
|
||||
}
|
||||
|
||||
message ReqGetCharacterCostumeData {}
|
||||
message ResGetCharacterCostumeData {
|
||||
repeated int32 costumeIds = 2;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,12 @@ namespace nksrv.Utils
|
||||
{
|
||||
msg = msg.Substring(msg.IndexOf("]") + 2);
|
||||
}
|
||||
Console.WriteLine(msg);
|
||||
|
||||
// ignore telemtry server errors
|
||||
if (!msg.StartsWith("POST /v2/dr/getsid: \"404 Not Found\""))
|
||||
{
|
||||
Console.WriteLine(msg);
|
||||
}
|
||||
|
||||
Console.ForegroundColor = fg;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user