public async Task<bool> Write(ValueList[] vl)
        {
            for (int i = 0; i < vl.Length; i++)
            {
                await WriteSingle(vl[i]);
            }

            //Write gets called every x seconds
            //to make sure data arrives as soon as possible, we flush the writer
            await Flush();
            return true;
        }
Ejemplo n.º 2
0
        public void Process(ValueList vl)
        {
            logger.Debug("Process: time = {0}, interval = {1}; host = {2}; plugin = {3}; plugin_instance = {4}; type = {5}; type_instance = {6};",
                vl.Time,
                vl.Interval,
                vl.Host,
                vl.Plugin,
                vl.PluginInstance,
                vl.Type,
                vl.TypeInstance);

            broadcast.Post(vl);
        }
        private async Task WriteSingle(ValueList vl)
        {
            int len = writer.Size;
            writer.Write(vl);

            if (writer.Size >= Protocol.BufferSize)
            {
                await client.SendAsync(writer.Bytes, len, host, port);

                writer.Reset();
                writer.Write(vl);
            }
        }
        public void Write(ValueList data)
        {
            WriteString(Protocol.TypeHost, data.Host);
            WriteNumber(Protocol.TypeTime, (uint)(data.Time / 1000));
            WriteString(Protocol.TypePlugin, data.Plugin);
            WriteString(Protocol.TypePluginInstance, data.PluginInstance);
            WriteString(Protocol.TypeType, data.Type);
            WriteString(Protocol.TypeTypeInstance, data.TypeInstance);

            List<DataSource> ds = TypesDB.Instance.GetType(data.Type);

            WriteNumber(Protocol.TypeInterval, data.Interval);
            WriteValues(ds, data.Values);
        }