Beispiel #1
0
    public static void SubscriberCallback(Zenoh.Net.Sample sample)
    {
        Console.WriteLine(">> [Subscription listener] Received ('{0}': '{1}')",
                          sample.ResName,
                          BitConverter.ToString(sample.Payload));

        // Encoding.UTF8.GetString(sample.Payload));
    }
    public static void SubscriberCallback(Zenoh.Net.Sample sample)
    {
        CDRReader reader  = new CDRReader(sample.Payload);
        var       userID  = reader.ReadInt32();
        var       message = reader.ReadString();

        Console.WriteLine("=== [Subscriber] Received : Message ({0}, {1})",
                          userID,
                          message);
    }
Beispiel #3
0
    private void OutCallback(Zenoh.Net.Sample sample)
    {
        // received type: rcl_interfaces/msg/Log
        CDRReader reader = new CDRReader(sample.Payload);
        // builtin_interfaces/Time stamp => int32 sec + uint32 nanosec
        var stamp_sec     = reader.ReadInt32();
        var stamp_nanosec = reader.ReadUInt32();
        // uint8 level
        var level = reader.ReadByte();
        // string name
        var name = reader.ReadString();
        // string msg
        var msg = reader.ReadString();
        // string file
        var file = reader.ReadString();
        // string function
        var function = reader.ReadString();
        // uint32 line
        var line = reader.ReadUInt32();

        Console.WriteLine("[{0}.{1}] [{2}]: {3}", stamp_sec, stamp_nanosec, name, msg);
    }