validateHeader() public method

public validateHeader ( Header header, string &error_message ) : bool
header Header
error_message string
return bool
コード例 #1
0
        public bool handleHeader(Header header)
        {
            if (!header.Values.Contains("topic"))
            {
                string msg = "Header from subscriber did not have the required element: topic";
                EDB.WriteLine(msg);
                connection.sendHeaderError(ref msg);
                return(false);
            }
            string      name            = (string)header.Values["topic"];
            string      client_callerid = (string)header.Values["callerid"];
            Publication pt = TopicManager.Instance.lookupPublication(name);

            if (pt == null)
            {
                string msg = "received a connection for a nonexistent topic [" + name + "] from [" +
                             connection.transport + "] [" + client_callerid + "]";
                EDB.WriteLine(msg);
                connection.sendHeaderError(ref msg);
                return(false);
            }
            string error_message = "";

            if (!pt.validateHeader(header, ref error_message))
            {
                connection.sendHeaderError(ref error_message);
                EDB.WriteLine(error_message);
                return(false);
            }
            destination_caller_id = client_callerid;
            connection_id         = ConnectionManager.Instance.GetNewConnectionID();
            name   = pt.Name;
            parent = pt;
            lock (parent)
            {
                max_queue = parent.MaxQueue;
            }
            IDictionary m = new Hashtable();

            m["type"]               = pt.DataType;
            m["md5sum"]             = pt.Md5sum;
            m["message_definition"] = pt.MessageDefinition;
            m["callerid"]           = this_node.Name;
            m["latching"]           = pt.Latch;
            connection.writeHeader(m, onHeaderWritten);
            pt.addSubscriberLink(this);
#if DEBUG
            EDB.WriteLine("Finalize transport subscriber link for " + name);
#endif
            return(true);
        }