Beispiel #1
0
        private bool PostSynHostEntryMessage(IMalockSocket socket, string key, string identity, HostEntry entry)
        {
            if (entry == null || string.IsNullOrEmpty(identity) || string.IsNullOrEmpty(key))
            {
                return(false);
            }
            MalockNnsMessage message = new MalockNnsMessage();

            message.Key      = key;
            message.Identity = identity;
            message.Sequence = MalockMessage.NewId();
            message.Command  = MalockNnsMessage.SERVER_NNS_COMMAND_SYN_HOSTENTRYINFO;
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter bw = new BinaryWriter(stream))
                {
                    message.Serialize(bw);
                    if (entry != null)
                    {
                        entry.Serialize(bw);
                    }
                    MalockMessage.TrySendMessage(socket, stream);
                }
            }
            return(true);
        }
Beispiel #2
0
        protected override void OnConnected(object sender, EventArgs e)
        {
            MalockNnsMessage message = new MalockNnsMessage();

            message.Command  = MalockNnsMessage.SERVER_NNS_COMMAND_DUMPHOSTENTRYINFO;
            message.Sequence = MalockMessage.NewId();
            MalockMessage.TrySendMessage(this, message);
        }
Beispiel #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;
            }
        }