Visual Basic (Declaration) | |
---|---|
Public Variables As VariableList |
Visual Basic (Usage) | ![]() |
---|---|
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 |
The following example demonstrates starting a simple agent supporting a MIB variable.
C# | ![]() |
---|---|
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 Basic | ![]() |
---|---|
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 |
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.
Target Platforms: Microsoft .NET Framework 2.0