Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any update! Amazing job! #3

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bolgrot.Core.Ankama.Protocol.SendMessages
{
public class ClientKeyMessage : CallNetworkMessage
{

public string key;


public ClientKeyMessage()
{
}

public ClientKeyMessage(string key)
{
this.key = key;

}
}
}
12 changes: 7 additions & 5 deletions Bolgrot.Core.Ankama.Protocol/SendMessages/ClientKeyMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@

namespace Bolgrot.Core.Ankama.Protocol.SendMessages
{
public class ClientKeyMessage : CallNetworkMessage
public class ChatClientMultiMessage : CallNetworkMessage
{

public string key;
public string content;
public int channel;


public ClientKeyMessage()
public ChatClientMultiMessage()
{
}

public ClientKeyMessage(string key)
public ChatClientMultiMessage(string content,int channel)
{
this.key = key;
this.content = content;
this.channel = channel;

}
}
Expand Down
20 changes: 20 additions & 0 deletions Bolgrot.Core.Ankama.Protocol/SendMessages/ConnectingMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Bolgrot.Core.Ankama.Protocol.SendMessages
{
public class ConnectingMessage
{
public string language { get; set; }
public string[] server { get; set; }
//public string client { get; set; }
//public string appVersion { get; set; }
//public string buildVersion { get; set; }

public ConnectingMessage(string language, string[] server/*, string client, string appVersion, string buildVersion*/)
{
this.language = language;
this.server = server;
//this.client = client;
//this.appVersion = appVersion;
//this.buildVersion = buildVersion;
}
}
}
5 changes: 4 additions & 1 deletion Bolgrot.Core.Common/Entity/Data/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ public partial class GraphicsPosition

public partial class Cell
{
[JsonProperty("id")] public int Id { get; set; }
[JsonProperty("id")]
public int Id {
get;
set; }

[JsonProperty("l", NullValueHandling = NullValueHandling.Ignore)]
public int L { get; set; }
Expand Down
36 changes: 36 additions & 0 deletions Bolgrot.Core.Common/Entity/WorldServer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using ServiceStack.DataAnnotations;

namespace Bolgrot.Core.Common.Entity
{
public class WorldServer : AbstractEntity
{
[PrimaryKey, AutoIncrement]
public override int Id { get; set; }

public string Name { get; set; }

public short Port { get; set; }

public string Address { get; set; }
public string Access { get; set; }

public bool RequireSubscription { get; set; }

public int Completion { get; set; }

public bool ServerSelectable { get; set; }

public int CharCapacity { get; set; }

[NotNull, AutoIncrement]
public int CharsCount { get; set; }
public int Status { get; set; }
[Default("CURRENT_TIMESTAMP()")]
public DateTime CreationDate { get; set; }
public byte Type { get; set; }

}
}
17 changes: 13 additions & 4 deletions Bolgrot.Core.Common/Managers/Frames/FrameIntercepterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ private static void LoadNetworkMessage()
object objInstance = Activator.CreateInstance(type);
if (messages.ContainsKey(type.Name.ToString()))
continue;

messages.Add(type.Name.ToString(), objInstance.GetType());
if (!messages.ContainsKey(type.Name.ToString()))
messages.Add(type.Name.ToString(), objInstance.GetType());
else
throw new Exception("messages ambiguous");
}
}

Expand Down Expand Up @@ -113,8 +115,14 @@ public static void Intercept(Client client, string messageData)
messageContent = data["data"].ToString();
}


if (client.Account == null && messageType != null && messageType.Name != null && messageType.Name != "AuthenticationTicketMessage")
{
//client.Disconnect();
return;
}

frame.Method.Invoke(frame.Instance, new object[] { client, JsonConvert.DeserializeObject(messageContent, messageType) });
//TODO: FIND the ticket in account db on TCP
break;
default:

Expand All @@ -123,7 +131,8 @@ public static void Intercept(Client client, string messageData)
var call = callsHandlers.FirstOrDefault(x => x.MessageType == callType.ToString());
if (call == null)
return;

//if(client.Account == null)
// return;
call.Method.Invoke(call.Instance, new object[] { client, message });

break;
Expand Down
2 changes: 2 additions & 0 deletions Bolgrot.Core.Common/Managers/Pathfinding/Pathfinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public List<Cell> DecompressKeyMovements(Map map, int[] keyMovements)
foreach (var cell in keyMovements)
{
int cellId = cell & 4095;
//if (map.Cells.ToList()[cellId] != null){
// decompressedCells.Add(map.Cells.ToList()[cellId]); }
decompressedCells.Add(map.Cells.ToList().FirstOrDefault(x => x.Id == cellId));
}

Expand Down
6 changes: 4 additions & 2 deletions Bolgrot.Core.Common/Network/AbstractServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Bolgrot.Core.Common.Network
public abstract class AbstractServer : WebSocketModule
{
public ConcurrentDictionary<string, Client> Clients { get; set; }

protected readonly NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();

public AbstractServer(string urlPath, bool enableConnectionWatchdog) : base(urlPath, enableConnectionWatchdog)
Expand Down Expand Up @@ -65,7 +66,7 @@ protected void DisconnectEventHandler(object sender, EventArgs eventArgs)
Disconnect(((Client) sender).ContextId);
}

private Task Disconnect(string contextId)
protected virtual Task Disconnect(string contextId)
{
if (!this.Clients.ContainsKey(contextId))
return null;
Expand All @@ -79,7 +80,7 @@ private Task Disconnect(string contextId)

return Task.CompletedTask;
}

protected void SendMessageEventHandler(object sender, SendMessageEventArgs eventArgs)
{
SendMessage(((Client) sender).ContextId, eventArgs.message);
Expand All @@ -98,5 +99,6 @@ private Task SendMessage(string contextId, string message)

return Task.CompletedTask;
}

}
}
5 changes: 4 additions & 1 deletion Bolgrot.Core.Common/Network/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public class Client
public IWebSocketContext Context {get;}

public Account Account { get; set; }


public string Language { get; set; }

public ConcurrentDictionary<long, string> MessagesQueues { get; }

public event EventHandler<EventArgs> OnDisconnect;
Expand Down Expand Up @@ -48,6 +50,7 @@ private void PrimusPing(object? state)
eventArgs.message = "4\"primus::ping::"+ DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() +"\"";
this.SendMessage(this, eventArgs);
}
//(context, "4{\"_messageType\":\"BasicAckMessage\",\"seq\":1,\"lastPacketId\":1,\"_isInitialized\":true}");

public void Send(NetworkMessage message)
{
Expand Down
33 changes: 33 additions & 0 deletions Bolgrot.Core.Common/Repository/AccountRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public interface IAccountRepository : IRepository<Account>
{
Task<Account> GetAccountByLogin(string login);
Task<Account> GetAccountByApiKey(string apikey);
Task<Account> GetAccountByTicket(string ticket);
}

public class AccountRepository : Repository<Account>, IAccountRepository
Expand Down Expand Up @@ -64,5 +65,37 @@ public async Task<Account> GetAccountByApiKey(string apikey)

return account;
}
public async Task<Account> GetAccountByTicket(string ticket)
{
var keyValue = this.Entities().FirstOrDefault(x => x.Value is Account && x.Value.Ticket == ticket);
var teste = this.Entities();
Account account = (keyValue.Key == null ? null : keyValue.Value);


if (account == null)
{
//string defaultname = DatabaseManager.Database;

this.DatabaseManager.Open();
//DatabaseManager.ChangeDatabase("bolgrot_auth");

var fetchedAccounts = await this.DatabaseManager.SelectAsync<Account>(x => x.Ticket == ticket);
//var fetchedAccounts = await this.DatabaseManager.SelectAsync<Account>($"SELECT * FROM bolgrot_auth.Account WHERE bolgrot_auth.Account.Ticket =\"{ticket}\"");
if (fetchedAccounts.Count != 0)
{
account = fetchedAccounts.First();
this.Entities().TryAdd(account.Id, account);
}
//DatabaseManager.ChangeDatabase(defaultname);
this.DatabaseManager.Close();

}

return account;
}
//public void ForceSave() {
// base.PersistEntities();
//}

}
}
19 changes: 19 additions & 0 deletions Bolgrot.Core.Common/Repository/WorldServerRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Bolgrot.Core.Common.Entity;

namespace Bolgrot.Core.Common.Repository
{
public interface IWorldServerRepository: IRepository<WorldServer>
{
}

public class WorldServerRepository : Repository<WorldServer>, IWorldServerRepository
{
public WorldServerRepository(IDbConnection databaseManager) : base(databaseManager)
{
}

}
}
10 changes: 10 additions & 0 deletions Bolgrot.Server.Auth/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static void Initialize()

//repository
builder.RegisterType<AccountRepository>().As<IAccountRepository>().SingleInstance();
builder.RegisterType<WorldServerRepository>().As<IWorldServerRepository>().SingleInstance();
builder.RegisterType<AuthRepositoryPersistManager>().AsSelf().OnActivating(e => e.Instance.StartPersister())
.AutoActivate()
.SingleInstance();
Expand All @@ -38,6 +39,15 @@ public static void Initialize()
// builder.RegisterType<DataManager>().As<IDataManager>().OnActivating(e => e.Instance.Initialize())
// .AutoActivate()
// .SingleInstance();
builder.RegisterType<WorldServerManager>().As<IWorldServerManager>()
.AutoActivate()
.SingleInstance();

builder.RegisterType<TicketManager>().As<ITicketManager>()
.AutoActivate()
.SingleInstance();


builder.RegisterType<HaapiManager>().As<IHaapiManager>().SingleInstance();

_container = builder.Build();
Expand Down
1 change: 1 addition & 0 deletions Bolgrot.Server.Auth/Controller/CmsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ public async Task GetData()
//
// await this.HttpContext.SendStringAsync(JsonConvert.SerializeObject(news, Formatting.Indented), "json", Encoding.Default);
}
///Almanax/GetEvent
}
}
5 changes: 3 additions & 2 deletions Bolgrot.Server.Auth/Controller/DataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task GetAssetsVersions()
var staticDataVersion = this.HttpContext.GetRequestQueryData().Get("staticDataVersion");
var assetsVersionsJson = new JObject();

assetsVersionsJson["assetsVersion"] = assetsVersion.ToString();
assetsVersionsJson["assetsVersion"] = "5";//assetsVersion.ToString();
assetsVersionsJson["staticDataVersion"] = staticDataVersion.ToString();
assetsVersionsJson["changedFiles"] = new JArray(new string[]{ });

Expand All @@ -68,7 +68,7 @@ public async Task GetApiDataMap()

if (!File.Exists($"data/map/{mapDataRequest.@class}.json"))
{
this.HttpContext.SendStringAsync(JsonConvert.SerializeObject("[]"), "application/json", Encoding.Default);
await this.HttpContext.SendStringAsync(JsonConvert.SerializeObject("[]"), "application/json", Encoding.Default);
}

StreamReader reader = new StreamReader($"data/map/{mapDataRequest.@class}.json");
Expand All @@ -79,5 +79,6 @@ public async Task GetApiDataMap()

await this.HttpContext.SendStringAsync(data, "application/json", Encoding.Default);
}
//api/logger ?
}
}
18 changes: 11 additions & 7 deletions Bolgrot.Server.Auth/Controller/HaapiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ public class HaapiController : WebApiController
[Route(HttpVerbs.Get, "/haapi/getForumTopicsList")]
public async Task GetForumTopicsList()
{
var lang = this.HttpContext.GetRequestQueryData().Get("lang");

var lang = this.HttpContext.GetRequestQueryData().Get("lang");
List<Topic> topics = new List<Topic>();
// topics.Add(new Topic(1, "Mise à jour 0.0.1", "Test", false, "2020-06-16T09:30:00+02:00"));
// topics.Add(new Topic(2, "Mise à jour 0.0.2", "[color=#2ecc71][b]MONSTRES[/b][/color][list][*]7pho au dessus XDDDDDD Les sorts du boss Nileza sont corrigés.[*]Les sorts du monstre Ecureuil d’Astrub sont corrigés.[/list]\n[color=#2ecc71][b]QUÊTES[/b][/color][list][*]Il est de nouveau possible de terminer la quête « Hérault de la Forêt » en étant aligné du côté de Bonta.[*]Il est de nouveau possible de terminer la quête « Pandala : Son air pur ».[*]Il est de nouveau possible de terminer la quête « Le règlement de comptes de Bworkékorall ».[/list]\n[color=#2ecc71][b]RECETTES[/b][/color][list][*]La recette de la Coiffe Cryochrone est corrigée.[*]Le texte du Plan de l’abreuvoir frigostien en Charme est corrigé afin de concorder avec la nouvelle recette.[*]Le texte de la Recette du masque de protection est corrigé afin de concorder avec la nouvelle recette.[/list]\n[color=#2ecc71][b]ÎLE DE L’ASCENSION[/b][/color][list][*]Une nouvelle rotation de l’île de l’Ascension commence dès maintenant ! [url=https://www.dofus-touch.com/fr/mmorpg/actualites/news/1196997-ile-ascension-rotation-9]En savoir plus[/url][/list]", false, "2020-06-02T09:00:00+02:00"));
// topics.Add(new Topic(3, "Mise à jour 0.0.3", "Test", false, ""));

topics.Add(new Topic() { Id = 1, Title = "Mise à jour 0.0.1", Content = "Test", Pinned = false, AddedDate = "2020-06-16T09:30:00+02:00" });
topics.Add(new Topic() { Id = 2, Title = "Mise à jour 0.0.2", Content = "[color=#2ecc71][b]MONSTRES[/b][/color][list][*]7pho au dessus XDDDDDD Les sorts du boss Nileza sont corrigés.[*]Les sorts du monstre Ecureuil d’Astrub sont corrigés.[/list]\n[color=#2ecc71][b]QUÊTES[/b][/color][list][*]Il est de nouveau possible de terminer la quête « Hérault de la Forêt » en étant aligné du côté de Bonta.[*]Il est de nouveau possible de terminer la quête « Pandala : Son air pur ».[*]Il est de nouveau possible de terminer la quête « Le règlement de comptes de Bworkékorall ».[/list]\n[color=#2ecc71][b]RECETTES[/b][/color][list][*]La recette de la Coiffe Cryochrone est corrigée.[*]Le texte du Plan de l’abreuvoir frigostien en Charme est corrigé afin de concorder avec la nouvelle recette.[*]Le texte de la Recette du masque de protection est corrigé afin de concorder avec la nouvelle recette.[/list]\n[color=#2ecc71][b]ÎLE DE L’ASCENSION[/b][/color][list][*]Une nouvelle rotation de l’île de l’Ascension commence dès maintenant ! [url=https://www.dofus-touch.com/fr/mmorpg/actualites/news/1196997-ile-ascension-rotation-9]En savoir plus[/url][/list]", Pinned = false, AddedDate = "2020-06-02T09:00:00+02:00" });
topics.Add(new Topic() { Id = 3, Title = "Mise à jour 0.0.3", Content = "Test", Pinned = false, AddedDate = "" });
//topics.Add(new Topic(1, "Mise à jour 0.0.1", "Test", false, "2020-06-16T09:30:00+02:00"));
//topics.Add(new Topic(2, "Mise à jour 0.0.2", "[color=#2ecc71][b]MONSTRES[/b][/color][list][*]7pho au dessus XDDDDDD Les sorts du boss Nileza sont corrigés.[*]Les sorts du monstre Ecureuil d’Astrub sont corrigés.[/list]\n[color=#2ecc71][b]QUÊTES[/b][/color][list][*]Il est de nouveau possible de terminer la quête « Hérault de la Forêt » en étant aligné du côté de Bonta.[*]Il est de nouveau possible de terminer la quête « Pandala : Son air pur ».[*]Il est de nouveau possible de terminer la quête « Le règlement de comptes de Bworkékorall ».[/list]\n[color=#2ecc71][b]RECETTES[/b][/color][list][*]La recette de la Coiffe Cryochrone est corrigée.[*]Le texte du Plan de l’abreuvoir frigostien en Charme est corrigé afin de concorder avec la nouvelle recette.[*]Le texte de la Recette du masque de protection est corrigé afin de concorder avec la nouvelle recette.[/list]\n[color=#2ecc71][b]ÎLE DE L’ASCENSION[/b][/color][list][*]Une nouvelle rotation de l’île de l’Ascension commence dès maintenant ! [url=https://www.dofus-touch.com/fr/mmorpg/actualites/news/1196997-ile-ascension-rotation-9]En savoir plus[/url][/list]", false, "2020-06-02T09:00:00+02:00"));
//topics.Add(new Topic(3, "Mise à jour 0.0.3", "Test", false, ""));

await this.HttpContext.SendStringAsync(JsonConvert.SerializeObject(topics, Formatting.Indented), "json", Encoding.Default);
}

Expand All @@ -40,6 +42,7 @@ public async Task GetForumPostsList()


[Route(HttpVerbs.Post, "/haapi/Ankama/v5/Api/CreateApiKey")]
[Route(HttpVerbs.Post, "/haapi/CreateApiKey")]
public async Task CreateApiKey()
{
string requestedPayload = await this.HttpContext.GetRequestBodyAsStringAsync();
Expand All @@ -59,6 +62,7 @@ public async Task CreateApiKey()
}

[EmbedIO.Routing.Route(HttpVerbs.Get, "/haapi/Ankama/v5/Account/CreateToken")]
[EmbedIO.Routing.Route(HttpVerbs.Get, "/haapi/CreateToken")]
public async Task CreateToken()
{

Expand All @@ -75,7 +79,7 @@ public async Task CreateToken()
{
this.HttpContext.Response.StatusCode = 601;
}

await this.HttpContext.SendStringAsync(response, "application/json", Encoding.Default);
}
}
Expand Down
Loading