aurora/Aurora/Backend/Server/Party/PartyServiceImpl.cs
2019-06-03 10:57:05 -04:00

50 lines
1.6 KiB
C#

using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Aurora.Backend.Proto;
using Aurora.Backend.Models;
namespace Aurora.Backend.Server.Party
{
class PartyServiceImpl : PartyService.PartyServiceBase
{
/// <summary>
/// Dictionary of party members. Key -> ClientId
/// </summary>
private Dictionary<string, PartyMember> _partyMembers;
public PartyServiceImpl()
{
_partyMembers = new Dictionary<string, PartyMember>();
}
public Dictionary<string, PartyMember> PartyMembers
{
get
{
return _partyMembers;
}
}
public override Task<JoinPartyResponse> JoinParty(JoinPartyRequest request, Grpc.Core.ServerCallContext context)
{
_partyMembers.Add(request.ClientId, new PartyMember()
{
Username = request.UserName,
Id = request.ClientId,
IpAddress = request.IpAddress,
Port = request.Port,
});
JoinPartyResponse response = new JoinPartyResponse() { Status = PartyJoinedStatusEnum.Connected };
return Task.FromResult(response);
}
public override Task<LeavePartyResponse> LeaveParty(LeavePartyRequest request, Grpc.Core.ServerCallContext context)
{
_partyMembers.Remove(request.ClientId);
LeavePartyResponse response = new LeavePartyResponse() { Status = PartyJoinedStatusEnum.Disconnected };
return Task.FromResult(response);
}
}
}