Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private void QueryHostEntry(MalockSocket socket, int sequence, string key)
        {
            string           identity;
            HostEntry        entry   = this.nnsTable.GetEntry(key, out identity);
            MalockNnsMessage message = new MalockNnsMessage();

            message.Key      = key;
            message.Sequence = sequence;
            message.Command  = MalockMessage.COMMON_COMMAND_ERROR;
            if (entry != null)
            {
                message.Command = MalockNnsMessage.CLIENT_COMMAND_QUERYHOSTENTRYINFO;
            }
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter bw = new BinaryWriter(stream))
                {
                    message.Serialize(bw);
                    if (entry != null)
                    {
                        entry.Serialize(bw);
                    }
                    MalockMessage.TrySendMessage(socket, stream);
                }
            }
            this.PostSynHostEntryMessage(this.nnsStanbyClient, key, identity, entry);
        }