PowerSNMP for .NET
RequestReceived Delegate
ExampleExample 




A reference to the Agent component.
The decoded request received.
The state argument from Agent.Start.
References the method to invoke on an IO completion thread as each RequestMessage is received.
Syntax
Public Delegate Sub RequestReceived( _
   ByVal agent As Agent, _
   ByVal request As RequestMessage, _
   ByVal state As Object _
) 
Dim instance As New RequestReceived(AddressOf HandlerMethod)
public delegate void RequestReceived( 
   Agent agent,
   RequestMessage request,
   object state
)
public: __gc __delegate void RequestReceived( 
   Agent* agent,
   RequestMessage* request,
   Object* state
)
public delegate void RequestReceived( 
   Agent^ agent,
   RequestMessage^ request,
   Object^ state
)

Parameters

agent
A reference to the Agent component.
request
The decoded request received.
state
The state argument from Agent.Start.
Example
The following example demonstrates starting a simple agent with one variable.
private void button1_Click(object sender, EventArgs e)
{
    //Add a variable to the agent
    agent1.Variables.Add(agent1.Mib.GetByNodeName(NodeName.sysContact).GetIid(),
        agent1.Mib.CreateVariable(NodeName.sysContact, "Systems Admin"));

    //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.CreateResponse(request), request.Origin);
}
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    'Add a variable to the agent
    agent1.Variables.Add(agent1.Mib.GetByNodeName(NodeName.sysContact).GetIid(), agent1.Mib.CreateVariable(NodeName.sysContact, "Systems Admin"))

    'Start listening for requests
    agent1.Start(AddressOf 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.CreateResponse(request), request.Origin)
End Sub
See Also

Reference

RequestReceived Members
Dart.Snmp Namespace


PowerSNMP for .NET Documentation Version 8.0
© 2024 Dart Communications. All Rights Reserved.
Send comments on this topic