Add remaining project files
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using DeluxeBackend.Models;
|
||||
using System.Numerics;
|
||||
using System.Security.Claims;
|
||||
using static DeluxeBackend.Enums;
|
||||
|
||||
namespace DeluxeBackend.Services
|
||||
{
|
||||
public interface IMessageService
|
||||
{
|
||||
Task<Message> SendMessage(Account fromPlayer, Account toPlayer, MessageType type, string data);
|
||||
}
|
||||
public class MessageService(ILiteDbService db, IConfiguration configuration, INotificationService ws) : IMessageService
|
||||
{
|
||||
private readonly ILiteDbService _db = db;
|
||||
private readonly IConfiguration _configuration = configuration;
|
||||
private readonly INotificationService _ws = ws;
|
||||
|
||||
|
||||
public async Task<Message> SendMessage(Account fromPlayer, Account toPlayer, MessageType type, string data)
|
||||
{
|
||||
var message = new Message
|
||||
{
|
||||
Player = toPlayer,
|
||||
FromPlayer = fromPlayer,
|
||||
Type = type,
|
||||
Data = data
|
||||
};
|
||||
|
||||
_db.Messages.Insert(message);
|
||||
|
||||
await _ws.SendToPlayer(toPlayer.Id, PushNotification.MessageReceived, message.ToDictionary());
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user