Migrate aurora-sharp-desktop
This commit is contained in:
46
aurora-sharp-desktop/Aurora/Services/Client/ClientService.cs
Normal file
46
aurora-sharp-desktop/Aurora/Services/Client/ClientService.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using Grpc.Core;
|
||||
using Aurora.Proto.Party;
|
||||
using Aurora.Services.Settings;
|
||||
|
||||
namespace Aurora.Services.Client
|
||||
{
|
||||
|
||||
public class ClientService : IClientService
|
||||
{
|
||||
private RemotePartyService.RemotePartyServiceClient _remotePartyClient;
|
||||
|
||||
private Channel _channel;
|
||||
private ISettingsService _settingsService;
|
||||
|
||||
public ClientService(ISettingsService settingsService)
|
||||
{
|
||||
this._settingsService = settingsService;
|
||||
}
|
||||
|
||||
public bool IsStarted
|
||||
{
|
||||
get
|
||||
{
|
||||
return _remotePartyClient != null;
|
||||
}
|
||||
}
|
||||
|
||||
public RemotePartyService.RemotePartyServiceClient RemotePartyServiceClient
|
||||
{
|
||||
get { return this._remotePartyClient; }
|
||||
}
|
||||
|
||||
public void Start(string hostname, string port)
|
||||
{
|
||||
_channel = new Channel(string.Format("{0}:{1}", hostname, port), ChannelCredentials.Insecure);
|
||||
|
||||
_remotePartyClient = new RemotePartyService.RemotePartyServiceClient(_channel);
|
||||
}
|
||||
|
||||
public async void Close()
|
||||
{
|
||||
await _channel.ShutdownAsync();
|
||||
_remotePartyClient = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using Aurora.Proto.Party;
|
||||
|
||||
namespace Aurora.Services.Client
|
||||
{
|
||||
public interface IClientService
|
||||
{
|
||||
bool IsStarted { get; }
|
||||
|
||||
RemotePartyService.RemotePartyServiceClient RemotePartyServiceClient { get; }
|
||||
|
||||
void Start(string hostname, string port);
|
||||
|
||||
void Close();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user