setHeaderReceivedCallback() public method

public setHeaderReceivedCallback ( HeaderReceivedFunc func ) : void
func HeaderReceivedFunc
return void
Esempio n. 1
0
        public bool initialize(Connection connection)
        {
#if DEBUG
            EDB.WriteLine("Init transport publisher link: " + parent.name);
#endif
            this.connection          = connection;
            connection.DroppedEvent += onConnectionDropped;
            if (connection.transport.getRequiresHeader())
            {
                connection.setHeaderReceivedCallback(onHeaderReceived);

                IDictionary header = new Hashtable();
                header["topic"]       = parent.name;
                header["md5sum"]      = parent.md5sum;
                header["callerid"]    = this_node.Name;
                header["type"]        = parent.datatype;
                header["tcp_nodelay"] = "1";
                connection.writeHeader(header, onHeaderWritten);
            }
            else
            {
                connection.read(4, onMessageLength);
            }
            return(true);
        }
        internal void initialize(Connection connection)
        {
            this.connection          = connection;
            connection.DroppedEvent += onConnectionDropped;
            connection.setHeaderReceivedCallback(onHeaderReceived);

            IDictionary dict = new Hashtable();

            dict["service"]    = name;
            dict["md5sum"]     = IRosService.generate((SrvTypes)Enum.Parse(typeof(SrvTypes), RequestType.ToString().Replace("__Request", "").Replace("__Response", ""))).MD5Sum();
            dict["callerid"]   = this_node.Name;
            dict["persistent"] = persistent ? "1" : "0";
            if (header_values != null)
            {
                foreach (object o in header_values.Keys)
                {
                    dict[o] = header_values[o];
                }
            }
            connection.writeHeader(dict, onHeaderWritten);
        }