Esempio n. 1
0
 /// <summary>
 /// 创建一个双机热备的 malock 服务器
 /// </summary>
 public MalockServer(MalockConfiguration configuration)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration it cannot be considered a null");
     }
     this.configuration  = configuration;
     this.malockEngine   = new MalockEngine(configuration);
     this.malockListener = new MalockSocketListener(configuration.Port);
     do
     {
         this.onAboredHandler        = this.ProcessAborted;
         this.onReceivedHandler      = this.ProcessReceived;
         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.onConnectedHandler = (sender, e) => this.ProcessAccept(sender, (MalockSocket)sender);
 }
Esempio n. 2
0
 public MalockStandbyClient(MalockEngine engine, string identity, string address, int listenport)
 {
     if (engine == null)
     {
         throw new ArgumentNullException("engine");
     }
     this.engine = engine;
     do
     {
         this.Identity   = identity;
         this.Address    = address;
         this.listenport = listenport;
     } while (false);
     this.socket           = new MalockInnetSocket(identity, address, listenport, MalockMessage.LINK_MODE_SERVER);
     this.socket.Received += this.OnReceived;
     this.socket.Run();
 }
Esempio n. 3
0
 public MalockTaskPoll(MalockEngine engine)
 {
     if (engine == null)
     {
         throw new ArgumentNullException("engine");
     }
     this.tables     = new ConcurrentDictionary <MalockTaskType, MalockTaskTable>();
     this.engine     = engine;
     this.workthread = Runnable.Run(() =>
     {
         while (true)
         {
             foreach (var kv in this.tables)
             {
                 this.Handle(kv.Key, kv.Value);
             }
             Thread.Sleep(1);
         }
     });
 }
Esempio n. 4
0
 public MalockStandbyClient(MalockEngine engine, MalockConfiguration configuration)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     if (engine == null)
     {
         throw new ArgumentNullException("engine");
     }
     this.configuration = configuration;
     this.engine        = engine;
     do
     {
         this.Identity   = configuration.Identity;
         this.Address    = this.GetAddress(configuration);
         this.listenport = configuration.Port;
     } while (false);
     this.socket            = new MalockInnetSocket(this.Identity, this.Address, this.GetListenPort(), MalockMessage.LINK_MODE_SERVER);
     this.socket.Received  += this.OnReceived;
     this.socket.Connected += this.OnConnected;
     this.socket.Aborted   += this.OnAborted;
     this.socket.Run();
 }