Beispiel #1
0
 public NnsServer(string identity, int port, string standbyNode)
 {
     if (port <= 0 || port > short.MaxValue)
     {
         throw new ArgumentOutOfRangeException("The specified server listening port is outside the 0~65535 range");
     }
     if (string.IsNullOrEmpty(standbyNode))
     {
         throw new ArgumentOutOfRangeException("You have specified an invalid standby server host address that is not allowed to be null or empty");
     }
     if (string.IsNullOrEmpty(identity))
     {
         throw new ArgumentOutOfRangeException("You have specified an invalid node Identity");
     }
     this.malockListener = new MalockSocketListener(port);
     this.nnsTable       = new NnsTable();
     do
     {
         this.onReceivedHandler      = this.ProcessReceived;
         this.onAboredHandler        = this.ProcessAborted;
         this.malockListener.Accept += (sender, e) =>
         {
             MalockSocket socket = (MalockSocket)e;
             lock (socket)
             {
                 socket.Received  += this.onReceivedHandler;
                 socket.Aborted   += this.onAboredHandler;
                 socket.Connected += this.onConnectedHandler;
                 socket.Run();
             }
         };
     } while (false);
     this.nnsStanbyClient    = new NnsStanbyClient(this.nnsTable, identity, standbyNode, port);
     this.onConnectedHandler = (sender, e) => this.ProcessAccept(sender, (MalockSocket)sender);
 }
Beispiel #2
0
 public NnsStanbyClient(NnsTable nnsTable, string identity, string address, int listenport) : base(identity, address, listenport)
 {
     if (nnsTable == null)
     {
         throw new ArgumentNullException("nnsTable");
     }
     this.nnsTable = nnsTable;
 }