Пример #1
0
        private void LoadAllInfo(Stream stream)
        {
            IList <HandleInfo> s = new List <HandleInfo>();

            if (!HandleInfo.Fill(s, stream))
            {
                this.socket.Abort();
                return;
            }
            MalockTable malock = this.engine.GetTable();

            lock (malock.GetSynchronizationObject())
            {
                foreach (HandleInfo i in s)
                {
                    if (i.Available)
                    {
                        malock.Exit(i.Key);
                    }
                    else
                    {
                        malock.Enter(i.Key, i.Identity);
                    }
                }
            }
        }
Пример #2
0
 private void ProcessServer(MalockSocket socket, MalockNodeMessage message)
 {
     if (message.Command == MalockNodeMessage.SERVER_COMMAND_SYN_ENTER)
     {
         socket.UserToken = message;
         MalockTable malock = this.malockEngine.GetTable();
         malock.Enter(message.Key, message.Identity);
     }
     else if (message.Command == MalockNodeMessage.SERVER_COMMAND_SYN_EXIT)
     {
         MalockTable malock = this.malockEngine.GetTable();
         malock.Exit(message.Key, message.Identity);
         do
         {
             this.malockEngine.AckPipelineExit(new MalockTaskInfo()
             {
                 Key      = message.Key,
                 Identity = message.Identity,
             });
         } while (false);
     }
     else if (message.Command == MalockNodeMessage.SERVER_COMMAND_SYN_FREE)
     {
         string[]    keys;
         MalockTable malock = this.malockEngine.GetTable();
         malock.Exit(message.Identity, out keys);
         this.malockEngine.AckPipelineEnter(message.Identity, keys);
     }
     else if (message.Command == MalockNodeMessage.SERVER_COMMAND_SYN_LOADALLINFO)
     {
         this.malockEngine.GetAllInfo(new MalockTaskInfo()
         {
             Identity = socket.Identity,
             Socket   = socket,
             Timeout  = -1,
             Type     = MalockTaskType.kGetAllInfo
         });
     }
 }
Пример #3
0
        private void ProcessAborted(object sender, EventArgs e)
        {
            MalockSocket socket = (MalockSocket)sender;

            if (socket.LinkMode == MalockMessage.LINK_MODE_CLIENT)
            {
                if (!string.IsNullOrEmpty(socket.Identity))
                {
                    this.malockEngine.Abort(new MalockTaskInfo()
                    {
                        Type      = MalockTaskType.kAbort,
                        Key       = null,
                        Stopwatch = null,
                        Timeout   = -1,
                        Sequence  = MalockMessage.NewId(),
                        Socket    = socket,
                        Identity  = socket.Identity,
                    });
                }
            }
            else if (socket.LinkMode == MalockMessage.LINK_MODE_SERVER)
            {
                MalockNodeMessage message = (MalockNodeMessage)socket.UserToken;
                if (message != null)
                {
                    string[]    keys;
                    MalockTable malock = this.malockEngine.GetTable();
                    malock.Exit(message.Identity, out keys);
                    this.malockEngine.AckPipelineEnter(message.Identity, keys);
                }
            }
            lock (socket)
            {
                socket.Aborted   -= this.onAboredHandler;
                socket.Connected -= this.onConnectedHandler;
                socket.Received  -= this.onReceivedHandler;
            }
        }
Пример #4
0
        private void Exit(MalockNodeMessage message)
        {
            MalockTable malock = this.engine.GetTable();

            malock.Exit(message.Key, message.Identity);
        }