2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 05:23:13 +00:00
This commit is contained in:
2024-06-21 16:37:48 +03:00
parent c04fc29810
commit 3a89a108db
49 changed files with 2095 additions and 1373 deletions

View File

@ -41,7 +41,6 @@ namespace Esiur.Net.IIP;
public class DistributedServer : NetworkServer<DistributedConnection>, IResource
{
[Attribute]
public string IP
@ -50,11 +49,30 @@ public class DistributedServer : NetworkServer<DistributedConnection>, IResource
set;
}
IMembership membership;
[Attribute]
public IMembership Membership
{
get;
set;
get => membership;
set
{
if (membership != null)
membership.Authorization -= Membership_Authorization;
membership = value;
if (membership != null)
membership.Authorization += Membership_Authorization;
}
}
private void Membership_Authorization(AuthorizationIndication indication)
{
lock (Connections.SyncRoot)
foreach (var connection in Connections)
if (connection.Session == indication.Session)
connection.ProcessAuthorization(indication.Results);
}
[Attribute]
@ -116,41 +134,6 @@ public class DistributedServer : NetworkServer<DistributedConnection>, IResource
//protected override void DataReceived(DistributedConnection sender, NetworkBuffer data)
//{
// //throw new NotImplementedException();
//}
//protected override void ClientConnected(DistributedConnection sender)
//{
// //Console.WriteLine("DistributedConnection Client Connected");
//}
//private void ConnectionReadyEventReceiver(DistributedConnection sender)
//{
// sender.OnReady -= ConnectionReadyEventReceiver;
// Warehouse.Put(sender, sender.LocalUsername, null, this);
//}
//public override void RemoveConnection(DistributedConnection connection)
//{
// connection.OnReady -= Sender_OnReady;
// //connection.Server = null;
// base.RemoveConnection(connection);
//}
//public override void AddConnection(DistributedConnection connection)
//{
// connection.OnReady += Sender_OnReady;
// connection.Server = this;
// base.AddConnection(connection);
//}
protected override void ClientConnected(DistributedConnection connection)
{
//Task.Delay(10000).ContinueWith((x) =>
@ -180,8 +163,6 @@ public class DistributedServer : NetworkServer<DistributedConnection>, IResource
{
//connection.OnReady -= ConnectionReadyEventReceiver;
//Warehouse.Remove(connection);
}
public KeyList<string, CallInfo?> Calls { get; } = new KeyList<string, CallInfo?>();
@ -195,7 +176,7 @@ public class DistributedServer : NetworkServer<DistributedConnection>, IResource
public DistributedServer MapCall(string call, Delegate handler)
{
var ft = FunctionTemplate.MakeFunctionTemplate(null, handler.Method);
Calls.Add(call, new CallInfo(){ Delegate = handler, Template = ft});
Calls.Add(call, new CallInfo() { Delegate = handler, Template = ft });
return this;
}