PowerSNMP for .NET CF
Variables Field
See Also  Send comments on this topic.
Dart.Snmp Namespace > Agent Class : Variables Field




A VariableList of Variable objects used to populate default response messages.

Syntax

Visual Basic (Declaration) 
Public Variables As VariableList
Visual Basic (Usage)Copy Code
Dim instance As Agent
Dim value As VariableList
 
value = instance.Variables
 
instance.Variables = value
C# 
public VariableList Variables
Managed Extensions for C++ 
public: VariableList* Variables
C++/CLI 
public:
VariableList^ Variables

Example

The following example demonstrates starting a simple agent supporting a MIB variable.
C#Copy Code
private void button1_Click(object sender, EventArgs e)
{
    //Add variable to agent
    agent1.Mib.CreateVariable(NodeName.sysContact, "Kara Thrace");
    agent1.Variables.Values.Add(agent1.Mib.CreateVariable(NodeName.sysContact, "Kara Thrace"));

    //Start listening for requests
    agent1.Start(agent1_MessageReceived, null);
}

private void agent1_MessageReceived(Agent agent, RequestMessage request, object state)
{
    //Create and send a response whenever a request is received
    agent1.Send(agent1.CreateDefaultResponse(request), request.Origin);
}
Visual BasicCopy Code
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
    'Add variable to agent
    agent1.Variables.Values.Add(agent1.Mib.CreateVariable(NodeName.sysContact, "Kara Thrace"))

    'Start listening for requests
    agent1.Start(agent1_MessageReceived, Nothing)
End Sub

Private Sub agent1_MessageReceived(ByVal agent As Agent, ByVal request As RequestMessage, ByVal state As Object)
    'Create and send a response whenever a request is received
    agent1.Send(agent1.CreateDefaultResponse(request), request.Origin)
End Sub

Remarks

When a SetMessage arrives, the Variable values are updated with information sent by the manager. When a GetMessage arrives, the Variable values are used to intialize the default ResponseMessage. If the Variable values contain OIDs that are in Mib, then the MibNode.Access property is checked for read-write access priviledges to the Agent.Variables list, and the ResponseMessage is constructed accordingly.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 4.2
© 2010 Dart Communications. All Rights Reserved.