2022-06-23 20:45:41 +04:00
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Ragon.Core;
|
|
|
|
|
|
|
|
|
|
namespace Game.Source;
|
|
|
|
|
|
2022-10-22 21:34:35 +04:00
|
|
|
public class ApplicationHandlerByKey: IApplicationHandler
|
2022-06-23 20:45:41 +04:00
|
|
|
{
|
|
|
|
|
private Configuration _configuration;
|
2022-10-22 21:34:35 +04:00
|
|
|
public ApplicationHandlerByKey(Configuration configuration)
|
2022-06-23 20:45:41 +04:00
|
|
|
{
|
|
|
|
|
_configuration = configuration;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-20 12:27:04 +04:00
|
|
|
public async Task OnAuthorizationRequest(string key, string name, byte[] additionalData, Action<string, string> accept, Action<uint> reject)
|
2022-06-23 20:45:41 +04:00
|
|
|
{
|
|
|
|
|
if (key == _configuration.Key)
|
|
|
|
|
{
|
|
|
|
|
var playerId = Guid.NewGuid().ToString();
|
|
|
|
|
var playerName = name;
|
|
|
|
|
|
|
|
|
|
accept(playerId, playerName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
reject(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-22 21:34:35 +04:00
|
|
|
|
|
|
|
|
public void OnCustomEvent(ushort peerId, ReadOnlySpan<byte> payload)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnJoin(ushort peerId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnLeave(ushort peerId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2022-06-23 20:45:41 +04:00
|
|
|
}
|