Reorganization
This commit is contained in:
60
Aurora/RemoteImpl/RemotePartyImpl.cs
Normal file
60
Aurora/RemoteImpl/RemotePartyImpl.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Aurora.Proto;
|
||||
using Aurora.Models;
|
||||
using Aurora.Services;
|
||||
|
||||
namespace Aurora.RemoteImpl
|
||||
{
|
||||
public class RemotePartyServiceImpl : RemotePartyService.RemotePartyServiceBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Dictionary of party members. Key -> ClientId
|
||||
/// </summary>
|
||||
private Dictionary<string, PartyMember> _partyMembers;
|
||||
|
||||
public RemotePartyServiceImpl()
|
||||
{
|
||||
_partyMembers = new Dictionary<string, PartyMember>();
|
||||
|
||||
//Add self to members list
|
||||
_partyMembers.Add(SettingsService.Instance.Username, new PartyMember
|
||||
{
|
||||
Username = SettingsService.Instance.Username,
|
||||
Id = "asdf",
|
||||
IpAddress = ServerService.Instance.Hostname,
|
||||
Port = ServerService.Instance.Port.ToString()
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
38
Aurora/RemoteImpl/RemotePlaybackImpl.cs
Normal file
38
Aurora/RemoteImpl/RemotePlaybackImpl.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using Aurora.Proto;
|
||||
using Aurora.Models;
|
||||
|
||||
namespace Aurora.RemoteImpl
|
||||
{
|
||||
public class RemotePlaybackServiceImpl : RemotePlaybackService.RemotePlaybackServiceBase
|
||||
{
|
||||
|
||||
public RemotePlaybackServiceImpl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override async Task GetPartyStream(Empty empty,
|
||||
Grpc.Core.IServerStreamWriter<Chunk> responseStream,
|
||||
Grpc.Core.ServerCallContext context)
|
||||
{
|
||||
throw new NotImplementedException("Working on it");
|
||||
// //Send stream
|
||||
// string cwd = Directory.GetCurrentDirectory();
|
||||
// using (FileStream fs = System.IO.File.OpenRead(Path.Combine(cwd, request.FileName)))
|
||||
// {
|
||||
// Console.WriteLine("Begin sending file");
|
||||
// byte[] buffer = new byte[2048]; // read in chunks of 2KB
|
||||
// int bytesRead;
|
||||
// while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) > 0)
|
||||
// {
|
||||
// Google.Protobuf.ByteString bufferByteString = Google.Protobuf.ByteString.CopyFrom(buffer);
|
||||
// await responseStream.WriteAsync(new Chunk { Content = bufferByteString });
|
||||
// }
|
||||
// Console.WriteLine("Done sending file");
|
||||
// };
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user