MessagePump.SetCommunicationLevel Method

Sets the communication level. Command and System messages are always occurred.

Namespace: Gamanet.C4.SDK
Assembly: Gamanet.C4.SimpleClient (in Gamanet.C4.SimpleClient.dll) Version: 2026.0.0.733
Syntax
C#
public void SetCommunicationLevel(
	ISimpleCollection<Guid> messageCategoryIds
)

Parameters

messageCategoryIds  ISimpleCollection<Guid>
The message category ids.

Implements

ISimpleClientMessagePumpV1.SetCommunicationLevel(ISimpleCollection<Guid>)
Remarks
Command and System messages are always occurred, it is not possible to filter it.
Example
The following example illustrates how to receive only commands and system from the MessagePump.
C#
using Gamanet.C4.SDK;
using Gamanet.C4.SDK.Enums.Devices;
using Gamanet.C4.SDK.Enums.Regions;
using Gamanet.C4.SimpleInterfaces;
using System;
using System.Collections.Generic;


class SetCommunicationLevelForCommands
{
    public static void Main()
    {
        // sender
        var client1 = new SimpleClient(ConnectorConfiguration.HttpClient, null);

        // receiver
        var client2 = new SimpleClient(ConnectorConfiguration.HttpClient, null);

        // connect to local server
        var connectionResult1 = client1.Connect(new Uri("https://localhost/"), "Support", "support", out var token1);
        var connectionResult2 = client2.Connect(new Uri("https://localhost/"), "Support", "support", out var token2);
        if (connectionResult1 != ConnectionResult.Successful && connectionResult2 != ConnectionResult.Successful)
        {
            Console.WriteLine("Connection1 unSuccessful, result: {0}", connectionResult1);
            Console.WriteLine("Connection2 unSuccessful, result: {0}", connectionResult2);
            return;
        }

        Console.WriteLine("Connection1 result: {0}", connectionResult1);
        Console.WriteLine("Connection2 result: {0}", connectionResult2);
        Console.WriteLine();



        // display received categories of messages
        client2.MessagePump.OnMessage += (sender, args) =>
        {
            if (args.Message.CategoryId == MessageCategory.Log)
            {
                Console.WriteLine($"Received log {((SimpleLog)args.Message.SimpleEntity).Name}");
            }
            else if (args.Message.CategoryId == MessageCategory.Command)
            {
                Console.WriteLine("Received command");
            }
        };

        // commands and system messges are by default
        client2.MessagePump.Start();

        // init command instance 
        var command = new SimpleCommand(Guid.NewGuid(), "", Guid.Empty,
            CommandCategory.DeviceOff);
        var commandMessage = new Message(Guid.Empty, EntityRoot.Device, command);

        // send command by client 1
        client1.MessagePump.Send(commandMessage);

        // create some region to show that logs from server are not received
        client1.Regions.Create(new SimpleRegion(Guid.NewGuid(), "Home", EntityRoot.Region, RegionCategory.Region));

        client1.Disconnect();

        Console.ReadLine();

        client2.MessagePump.Stop();
        client2.Disconnect();

        // The example displays the following output:
        //  Connection1 result: Successful
        //  Connection2 result: Successful

        //  Received command
    }
}
The following example illustrates how to receive logs from the MessagePump.
C#
using Gamanet.C4.SDK;
using Gamanet.C4.SDK.Enums.Devices;
using Gamanet.C4.SDK.Enums.Regions;
using Gamanet.C4.SimpleInterfaces;
using System;
using System.Collections.Generic;

class SetCommunicationLevelForCommandsAndLogs : ExampleBase
{
    public override void Execute()
    {
        // sender
        var client1 = new SimpleClient(ConnectorConfiguration.HttpClient, null);

        // receiver
        var client2 = new SimpleClient(ConnectorConfiguration.HttpClient, null);

        // connect to local server
        var connectionResult1 = client1.Connect(new Uri("https://localhost/"), "Support", "support", out var token1);
        var connectionResult2 = client2.Connect(new Uri("https://localhost/"), "Support", "support", out var token2);
        if (connectionResult1 != ConnectionResult.Successful && connectionResult2 != ConnectionResult.Successful)
        {
            Console.WriteLine("Connection1 unSuccessful, result: {0}", connectionResult1);
            Console.WriteLine("Connection2 unSuccessful, result: {0}", connectionResult2);
            return;
        }

        Console.WriteLine("Connection1 result: {0}", connectionResult1);
        Console.WriteLine("Connection2 result: {0}", connectionResult2);
        Console.WriteLine();

        // display received categories of messages
        client2.MessagePump.OnMessage += (sender, args) =>
        {
            if (args.Message.CategoryId == MessageCategory.Log)
            {
                Console.WriteLine($"Received log {((SimpleLog)args.Message.SimpleEntity).Name}");
            }
            else if (args.Message.CategoryId == MessageCategory.Command)
            {
                Console.WriteLine("Received command");
            }
        };
       // client1.MessagePump.Start();
        client2.MessagePump.Start();

        // setup client2 to receive logs
        // command and system are always occurred
        client2.MessagePump.SetCommunicationLevel(new SimpleCollection<Guid>() { MessageCategory.Log });

        // init command instance 
        var command = new SimpleCommand(Guid.NewGuid(), "", Guid.Empty,
            CommandCategory.DeviceOff);
        var commandMessage = new Message(Guid.Empty, EntityRoot.Device, command);

        // send command by client 1
        client1.MessagePump.Send(commandMessage);

        // create some region to show that logs from server are not received
        client1.Regions.Create(new SimpleRegion(Guid.NewGuid(), "Home", EntityRoot.Region, RegionCategory.Region));

        client1.Disconnect();

        Console.ReadLine();

        client2.MessagePump.Stop();
        client2.Disconnect();

        // The example displays the following output:
        // Connection1 result: Successful
        // Connection2 result: Successful

        // Received log 'Support' created 'Home' under 'RegionRoot'.
        // Received command
        // Received log Command to device 'DeviceRoot' was issued.
    }
}
See Also

Reference

MessagePump Class
Gamanet.C4.SDK Namespace