Can now somewhat reliably join a party
This commit is contained in:
parent
0d64c0732e
commit
2a3290defc
@ -20,11 +20,6 @@
|
|||||||
VerticalOptions="Center"/>
|
VerticalOptions="Center"/>
|
||||||
<Entry
|
<Entry
|
||||||
x:Name="HostnameEntry"/>
|
x:Name="HostnameEntry"/>
|
||||||
<Label
|
|
||||||
Text="Port"
|
|
||||||
VerticalOptions="Center"/>
|
|
||||||
<Entry
|
|
||||||
x:Name="PortEntry"/>
|
|
||||||
<Button
|
<Button
|
||||||
HorizontalOptions="Center"
|
HorizontalOptions="Center"
|
||||||
x:Name="buttonHost"
|
x:Name="buttonHost"
|
||||||
|
@ -31,10 +31,6 @@ namespace Aurora.Design.Components.HostSelector
|
|||||||
{
|
{
|
||||||
Hostname = e.NewTextValue;
|
Hostname = e.NewTextValue;
|
||||||
};
|
};
|
||||||
PortEntry.TextChanged += (sender, e) =>
|
|
||||||
{
|
|
||||||
Port = e.NewTextValue;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -119,33 +115,6 @@ namespace Aurora.Design.Components.HostSelector
|
|||||||
|
|
||||||
#endregion Hostname property
|
#endregion Hostname property
|
||||||
|
|
||||||
#region Port property
|
|
||||||
public static readonly BindableProperty PortProperty =
|
|
||||||
BindableProperty.Create(propertyName: "Port",
|
|
||||||
returnType: typeof(string),
|
|
||||||
declaringType: typeof(HostSelector),
|
|
||||||
defaultBindingMode: BindingMode.TwoWay,
|
|
||||||
propertyChanged: OnPortChanged);
|
|
||||||
|
|
||||||
public string Port
|
|
||||||
{
|
|
||||||
get { return (string)GetValue(PortProperty); }
|
|
||||||
set { SetValue(PortProperty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OnPortChanged(BindableObject bindable, object oldValue, object newValue)
|
|
||||||
{
|
|
||||||
string newVal = newValue as string;
|
|
||||||
HostSelector instance = bindable as HostSelector;
|
|
||||||
if (instance.PortEntry.Text != newVal)
|
|
||||||
{
|
|
||||||
instance.PortEntry.Text = newVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Port property
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Collections.Specialized;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Aurora.Design.Components.HorizontalList;
|
using Aurora.Proto;
|
||||||
using Aurora.Models;
|
|
||||||
|
|
||||||
namespace Aurora.Design.Components.MemberList
|
namespace Aurora.Design.Components.MemberList
|
||||||
{
|
{
|
||||||
public partial class MemberList : ContentView
|
public partial class MemberList : ContentView
|
||||||
{
|
{
|
||||||
|
private static ObservableCollection<PartyMember> _newSource;
|
||||||
public MemberList()
|
public MemberList()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -22,7 +23,7 @@ namespace Aurora.Design.Components.MemberList
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static readonly BindableProperty MembersProperty =
|
public static readonly BindableProperty MembersProperty =
|
||||||
BindableProperty.Create(propertyName: "Members",
|
BindableProperty.Create(propertyName: "Members",
|
||||||
returnType: typeof(IEnumerable<PartyMember>),
|
returnType: typeof(ObservableCollection<PartyMember>),
|
||||||
declaringType: typeof(MemberList),
|
declaringType: typeof(MemberList),
|
||||||
defaultBindingMode: BindingMode.Default,
|
defaultBindingMode: BindingMode.Default,
|
||||||
propertyChanged: OnMembersChanged);
|
propertyChanged: OnMembersChanged);
|
||||||
@ -31,11 +32,11 @@ namespace Aurora.Design.Components.MemberList
|
|||||||
/// Backing property for MembersProperty
|
/// Backing property for MembersProperty
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public IEnumerable<PartyMember> Members
|
public ObservableCollection<PartyMember> Members
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return (IEnumerable<PartyMember>)GetValue(MembersProperty);
|
return (ObservableCollection<PartyMember>)GetValue(MembersProperty);
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@ -55,8 +56,10 @@ namespace Aurora.Design.Components.MemberList
|
|||||||
var membersList = control.FindByName("MembersHorizontalList") as HorizontalList.HorizontalList;
|
var membersList = control.FindByName("MembersHorizontalList") as HorizontalList.HorizontalList;
|
||||||
if (membersList != null)
|
if (membersList != null)
|
||||||
{
|
{
|
||||||
membersList.ItemsSource = newValue as IEnumerable<PartyMember>;
|
_newSource = newValue as ObservableCollection<PartyMember>;
|
||||||
|
membersList.ItemsSource = newValue as ObservableCollection<PartyMember>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
<hs:HostSelector
|
<hs:HostSelector
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Hostname="{Binding Hostname}"
|
Hostname="{Binding Hostname}"
|
||||||
Port="{Binding Port}"
|
|
||||||
HostCommand="{Binding HostCommand}"
|
HostCommand="{Binding HostCommand}"
|
||||||
JoinCommand="{Binding JoinCommand}"
|
JoinCommand="{Binding JoinCommand}"
|
||||||
IsVisible="{Binding IsSelectingHost}"/>
|
IsVisible="{Binding IsSelectingHost}"/>
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using Aurora.Executors;
|
using Aurora.Executors;
|
||||||
using Aurora.Design.Components.HostSelector;
|
using Aurora.Proto;
|
||||||
using Aurora.Services;
|
|
||||||
using Aurora.Models;
|
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Aurora.Design.Views.Party
|
namespace Aurora.Design.Views.Party
|
||||||
@ -23,8 +21,6 @@ namespace Aurora.Design.Views.Party
|
|||||||
|
|
||||||
private string _hostname;
|
private string _hostname;
|
||||||
|
|
||||||
private string _port;
|
|
||||||
|
|
||||||
private ObservableCollection<PartyMember> _members;
|
private ObservableCollection<PartyMember> _members;
|
||||||
|
|
||||||
|
|
||||||
@ -66,12 +62,6 @@ namespace Aurora.Design.Views.Party
|
|||||||
set { SetProperty(ref _hostname, value); }
|
set { SetProperty(ref _hostname, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Port
|
|
||||||
{
|
|
||||||
get { return _port; }
|
|
||||||
set { SetProperty(ref _port, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Properties
|
#endregion Properties
|
||||||
|
|
||||||
|
|
||||||
@ -86,8 +76,10 @@ namespace Aurora.Design.Views.Party
|
|||||||
private void OnJoinExecute()
|
private void OnJoinExecute()
|
||||||
{
|
{
|
||||||
_executor = BaseExecutor.CreateExecutor<ClientExecutor>();
|
_executor = BaseExecutor.CreateExecutor<ClientExecutor>();
|
||||||
Int32.TryParse(this.Port, out int intPort);
|
_executor.Connect(this.Hostname);
|
||||||
_executor.Initialize();
|
|
||||||
|
SetUpMembers();
|
||||||
|
|
||||||
State(PartyState.Connecting);
|
State(PartyState.Connecting);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,24 +90,12 @@ namespace Aurora.Design.Views.Party
|
|||||||
|
|
||||||
private void OnHostExecute()
|
private void OnHostExecute()
|
||||||
{
|
{
|
||||||
Int32.TryParse(this.Port, out int intPort);
|
|
||||||
//Init gRPC server
|
|
||||||
ServerService.Instance.Initialize(this.Hostname, intPort);
|
|
||||||
|
|
||||||
//Instantiate and initialize all executors
|
//Instantiate and initialize all executors
|
||||||
_executor = BaseExecutor.CreateExecutor<HostExecutor>();
|
_executor = BaseExecutor.CreateExecutor<HostExecutor>();
|
||||||
_executor.Initialize();
|
_executor.Connect(this.Hostname);
|
||||||
|
|
||||||
//start gRPC server
|
SetUpMembers();
|
||||||
|
|
||||||
ServerService.Instance.Start();
|
|
||||||
|
|
||||||
_members = _executor.PartyMembers;
|
|
||||||
OnPropertyChanged("Members");
|
|
||||||
_executor.PartyMembers.CollectionChanged += (sender, e) =>
|
|
||||||
{
|
|
||||||
OnPropertyChanged("Members");
|
|
||||||
};
|
|
||||||
|
|
||||||
//Change state
|
//Change state
|
||||||
State(PartyState.Connecting);
|
State(PartyState.Connecting);
|
||||||
@ -129,5 +109,18 @@ namespace Aurora.Design.Views.Party
|
|||||||
|
|
||||||
#endregion Commands
|
#endregion Commands
|
||||||
|
|
||||||
|
private void SetUpMembers()
|
||||||
|
{
|
||||||
|
_members = _executor.PartyMembers;
|
||||||
|
OnPropertyChanged("Members");
|
||||||
|
_executor.PartyMembers.CollectionChanged += (sender, e) =>
|
||||||
|
{
|
||||||
|
if (_executor != null)
|
||||||
|
{
|
||||||
|
_members = _executor.PartyMembers;
|
||||||
|
}
|
||||||
|
OnPropertyChanged("Members");
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,10 +9,19 @@
|
|||||||
<StackLayout
|
<StackLayout
|
||||||
Orientation="Horizontal">
|
Orientation="Horizontal">
|
||||||
<Label
|
<Label
|
||||||
|
VerticalOptions="Center"
|
||||||
Text="Username"/>
|
Text="Username"/>
|
||||||
<Entry
|
<Entry
|
||||||
Text="{Binding Username}"/>
|
Text="{Binding Username}"/>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
<StackLayout
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Label
|
||||||
|
VerticalOptions="Center"
|
||||||
|
Text="Default Port"/>
|
||||||
|
<Entry
|
||||||
|
Text="{Binding Port}"/>
|
||||||
|
</StackLayout>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ContentView.Content>
|
</ContentView.Content>
|
||||||
</ContentView>
|
</ContentView>
|
@ -19,5 +19,16 @@ namespace Aurora.Design.Views.Profile
|
|||||||
OnPropertyChanged("Username");
|
OnPropertyChanged("Username");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Port
|
||||||
|
{
|
||||||
|
get { return SettingsService.Instance.DefaultPort.ToString(); }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Int32.TryParse(value, out int portNum);
|
||||||
|
SettingsService.Instance.DefaultPort = portNum;
|
||||||
|
OnPropertyChanged("Port");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using Aurora.Models;
|
using Aurora.Proto;
|
||||||
|
|
||||||
namespace Aurora.Executors
|
namespace Aurora.Executors
|
||||||
{
|
{
|
||||||
@ -38,9 +38,7 @@ namespace Aurora.Executors
|
|||||||
return executor;
|
return executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Initialize();
|
public abstract void Connect(string hostname);
|
||||||
|
|
||||||
public abstract void Run();
|
|
||||||
|
|
||||||
public abstract void Close();
|
public abstract void Close();
|
||||||
|
|
||||||
|
@ -1,31 +1,48 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using Grpc.Core;
|
||||||
|
using Aurora.Proto;
|
||||||
using Aurora.Models;
|
using Aurora.Models;
|
||||||
using Aurora.Executors;
|
using Aurora.Services;
|
||||||
|
|
||||||
namespace Aurora.Executors
|
namespace Aurora.Executors
|
||||||
{
|
{
|
||||||
public class ClientExecutor : BaseExecutor
|
public class ClientExecutor : BaseExecutor
|
||||||
{
|
{
|
||||||
|
private Channel _channel;
|
||||||
|
private RemotePartyService.RemotePartyServiceClient _remotePartyClient;
|
||||||
|
private RemotePlaybackService.RemotePlaybackServiceClient _remotePlaybackClient;
|
||||||
|
|
||||||
|
private ObservableCollection<PartyMember> _partyMembers;
|
||||||
|
|
||||||
public ClientExecutor()
|
public ClientExecutor()
|
||||||
{
|
{
|
||||||
|
_partyMembers = new ObservableCollection<PartyMember>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
public override ObservableCollection<PartyMember> PartyMembers
|
public override ObservableCollection<PartyMember> PartyMembers
|
||||||
{
|
{
|
||||||
get { return null; }
|
get { return _partyMembers; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Properties
|
#endregion Properties
|
||||||
|
|
||||||
public override void AddToQueue()
|
public override void Connect(string hostname)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_channel = new Channel(string.Format("{0}:{1}", hostname, SettingsService.Instance.DefaultPort), ChannelCredentials.Insecure);
|
||||||
|
|
||||||
|
_remotePartyClient = new RemotePartyService.RemotePartyServiceClient(_channel);
|
||||||
|
_remotePlaybackClient = new RemotePlaybackService.RemotePlaybackServiceClient(_channel);
|
||||||
|
|
||||||
|
JoinParty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Close()
|
public override async void Close()
|
||||||
|
{
|
||||||
|
await _channel.ShutdownAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void AddToQueue()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@ -40,19 +57,33 @@ namespace Aurora.Executors
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void RemoveFromQueue()
|
public override void RemoveFromQueue()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Run()
|
private async void JoinParty()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
await _remotePartyClient.JoinPartyAsync(new JoinPartyRequest
|
||||||
|
{
|
||||||
|
UserName = SettingsService.Instance.Username,
|
||||||
|
});
|
||||||
|
|
||||||
|
MembersResponse resposne = _remotePartyClient.GetPartyMembers(new Empty());
|
||||||
|
//Add members
|
||||||
|
foreach (PartyMember member in resposne.Members)
|
||||||
|
{
|
||||||
|
_partyMembers.Add(member);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Remove out of date members
|
||||||
|
foreach (PartyMember member in _partyMembers)
|
||||||
|
{
|
||||||
|
if (!resposne.Members.Contains(member))
|
||||||
|
{
|
||||||
|
_partyMembers.Remove(member);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,11 +19,17 @@ namespace Aurora.Executors
|
|||||||
_remotePlaybackImpl = new RemotePlaybackServiceImpl();
|
_remotePlaybackImpl = new RemotePlaybackServiceImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Connect(string hostname)
|
||||||
{
|
{
|
||||||
|
//Initialize gRPC server
|
||||||
|
ServerService.Instance.Initialize(hostname);
|
||||||
|
|
||||||
//Register grpc RemoteService with singleton server service
|
//Register grpc RemoteService with singleton server service
|
||||||
ServerService.Instance.RegisterService(RemotePartyService.BindService(_remotePartyServiceImpl));
|
ServerService.Instance.RegisterService(RemotePartyService.BindService(_remotePartyServiceImpl));
|
||||||
ServerService.Instance.RegisterService(RemotePlaybackService.BindService(_remotePlaybackImpl));
|
ServerService.Instance.RegisterService(RemotePlaybackService.BindService(_remotePlaybackImpl));
|
||||||
|
|
||||||
|
//start gRPC server
|
||||||
|
ServerService.Instance.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
@ -58,10 +64,5 @@ namespace Aurora.Executors
|
|||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Run()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Aurora.Models
|
|
||||||
{
|
|
||||||
public class PartyMember
|
|
||||||
{
|
|
||||||
public PartyMember()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Username { get; set; }
|
|
||||||
public string Id { get; set; }
|
|
||||||
public string IpAddress { get; set; }
|
|
||||||
public string Port { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,13 +8,11 @@ service RemotePartyService {
|
|||||||
//Party Service
|
//Party Service
|
||||||
rpc JoinParty(JoinPartyRequest) returns (JoinPartyResponse);
|
rpc JoinParty(JoinPartyRequest) returns (JoinPartyResponse);
|
||||||
rpc LeaveParty(LeavePartyRequest) returns (LeavePartyResponse);
|
rpc LeaveParty(LeavePartyRequest) returns (LeavePartyResponse);
|
||||||
|
rpc GetPartyMembers(Empty) returns (MembersResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
message JoinPartyRequest {
|
message JoinPartyRequest {
|
||||||
string clientId = 1;
|
|
||||||
string userName = 2;
|
string userName = 2;
|
||||||
string ipAddress = 3;
|
|
||||||
string port = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message JoinPartyResponse {
|
message JoinPartyResponse {
|
||||||
@ -29,6 +27,19 @@ message LeavePartyResponse {
|
|||||||
PartyJoinedStatusEnum status = 1;
|
PartyJoinedStatusEnum status = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message PartyMember {
|
||||||
|
string userName = 1;
|
||||||
|
string id = 2;
|
||||||
|
string ipAddress = 3;
|
||||||
|
int32 port = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MembersResponse {
|
||||||
|
repeated PartyMember members = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum PartyJoinedStatusEnum {
|
enum PartyJoinedStatusEnum {
|
||||||
Connected = 0;
|
Connected = 0;
|
||||||
Disconnected = 1;
|
Disconnected = 1;
|
||||||
|
@ -22,10 +22,10 @@ namespace Aurora.RemoteImpl
|
|||||||
//Add self to members list
|
//Add self to members list
|
||||||
_partyMembers.Add(new PartyMember
|
_partyMembers.Add(new PartyMember
|
||||||
{
|
{
|
||||||
Username = SettingsService.Instance.Username,
|
UserName = SettingsService.Instance.Username,
|
||||||
Id = "asdf",
|
Id = "asdf",
|
||||||
IpAddress = ServerService.Instance.Hostname,
|
IpAddress = ServerService.Instance.Hostname,
|
||||||
Port = ServerService.Instance.Port.ToString()
|
Port = ServerService.Instance.Port
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,10 +41,8 @@ namespace Aurora.RemoteImpl
|
|||||||
{
|
{
|
||||||
_partyMembers.Add(new PartyMember()
|
_partyMembers.Add(new PartyMember()
|
||||||
{
|
{
|
||||||
Username = request.UserName,
|
UserName = request.UserName,
|
||||||
Id = request.ClientId,
|
IpAddress = context.Host,
|
||||||
IpAddress = request.IpAddress,
|
|
||||||
Port = request.Port,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
JoinPartyResponse response = new JoinPartyResponse() { Status = PartyJoinedStatusEnum.Connected };
|
JoinPartyResponse response = new JoinPartyResponse() { Status = PartyJoinedStatusEnum.Connected };
|
||||||
@ -57,5 +55,12 @@ namespace Aurora.RemoteImpl
|
|||||||
LeavePartyResponse response = new LeavePartyResponse() { Status = PartyJoinedStatusEnum.Disconnected };
|
LeavePartyResponse response = new LeavePartyResponse() { Status = PartyJoinedStatusEnum.Disconnected };
|
||||||
return Task.FromResult(response);
|
return Task.FromResult(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Task<MembersResponse> GetPartyMembers(Empty empty, Grpc.Core.ServerCallContext context)
|
||||||
|
{
|
||||||
|
MembersResponse response = new MembersResponse();
|
||||||
|
response.Members.AddRange(_partyMembers);
|
||||||
|
return Task.FromResult(response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ namespace Aurora.Services
|
|||||||
public class ServerService : BaseService<ServerService>
|
public class ServerService : BaseService<ServerService>
|
||||||
{
|
{
|
||||||
private string _hostname = "127.0.0.1";
|
private string _hostname = "127.0.0.1";
|
||||||
private int _port = 50001;
|
private int _port = SettingsService.Instance.DefaultPort;
|
||||||
private Grpc.Core.Server _server;
|
private Grpc.Core.Server _server;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -28,9 +28,8 @@ namespace Aurora.Services
|
|||||||
get { return _hostname; }
|
get { return _hostname; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(string hostname, int port)
|
public void Initialize(string hostname)
|
||||||
{
|
{
|
||||||
this._port = port;
|
|
||||||
this._hostname = hostname;
|
this._hostname = hostname;
|
||||||
_server = new Grpc.Core.Server
|
_server = new Grpc.Core.Server
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,8 @@ namespace Aurora.Services
|
|||||||
public class SettingsService : BaseService<SettingsService>
|
public class SettingsService : BaseService<SettingsService>
|
||||||
{
|
{
|
||||||
private Lazy<ISettings> _appSettings;
|
private Lazy<ISettings> _appSettings;
|
||||||
|
private string _usernameKey = "username";
|
||||||
|
private string _defaultPortKey = "port";
|
||||||
|
|
||||||
public SettingsService()
|
public SettingsService()
|
||||||
{
|
{
|
||||||
@ -30,8 +32,6 @@ namespace Aurora.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _usernameKey = "username";
|
|
||||||
|
|
||||||
public string Username
|
public string Username
|
||||||
{
|
{
|
||||||
get { return AppSettings.GetValueOrDefault(_usernameKey, ""); }
|
get { return AppSettings.GetValueOrDefault(_usernameKey, ""); }
|
||||||
@ -40,5 +40,12 @@ namespace Aurora.Services
|
|||||||
AppSettings.AddOrUpdateValue(_usernameKey, value);
|
AppSettings.AddOrUpdateValue(_usernameKey, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int DefaultPort
|
||||||
|
{
|
||||||
|
get { return AppSettings.GetValueOrDefault(_defaultPortKey, 4005); }
|
||||||
|
set { AppSettings.AddOrUpdateValue(_defaultPortKey, value); }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user