PowerSNMP for .NET
InformMessage Class
Members  Example 




The InformMessage class is used to send information between SNMP version 2/ 3 managers. Serializable using BinaryFormatter and XmlSerializer.
Object Model
InformMessage ClassDecodingException ClassVariableCollection ClassVariable Class
Syntax
<SerializableAttribute()>
Public Class InformMessage 
   Inherits RequestMessage
Dim instance As InformMessage
[Serializable()]
public class InformMessage : RequestMessage 
[Serializable()]
public __gc class InformMessage : public RequestMessage 
[Serializable()]
public ref class InformMessage : public RequestMessage 
Remarks

This message is used to send variables from an agent or manager to a manager. A ResponseMessage containing the same variables is used to acknowledge the receipt of the information.

Example
The following example demonstrates sending an inform message from a manager to a manager and receiving the response.
private void button1_Click(object sender, EventArgs e)
{
    //Send an inform request on a worker thread
    manager1.Start(sendInform, null);
}

private void sendInform(SnmpSocket managerSocket, object state)
{
    //Create an inform message and send it to a manager
    InformMessage inform = new InformMessage();

    //The inform includes this manager's uptime
    inform.Variables.Add(manager1.Mib.CreateVariable(NodeName.sysUpTime, manager1.Security.AuthoritativeEngine.Time.ToString()));
    manager1.Marshal(new ResponseMessage[] { managerSocket.GetResponse(inform, remoteManagerAddress) }, "", null);
}

void manager1_Message(object sender, MessageEventArgs e)
{
    label1.Text = "Manager received response to inform:\r\n" + ((ResponseMessage)e.Messages[0]).Variables[0].Value.ToString();
}
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
    'Send an inform request on a worker thread
    manager1.Start(AddressOf sendInform, Nothing)
End Sub

Private Sub sendInform(ByVal managerSocket As SnmpSocket, ByVal state As Object)
    'Create an inform message and send it to a manager
    Dim inform As New InformMessage()

    'The inform includes this manager's uptime
    inform.Variables.Add(manager1.Mib.CreateVariable(NodeName.sysUpTime, manager1.Security.AuthoritativeEngine.Time.ToString()))
    manager1.Marshal(New ResponseMessage() { managerSocket.GetResponse(inform, remoteManagerAddress) }, "", Nothing)
End Sub

Private Sub manager1_Message(ByVal sender As Object, ByVal e As MessageEventArgs)
    label1.Text = "Manager received response to inform:" & vbCrLf & CType(e.Messages(0), ResponseMessage).Variables(0).Value.ToString()
End Sub
Inheritance Hierarchy

System.Object
   Dart.Snmp.MessageBase
      Dart.Snmp.StandardMessage
         Dart.Snmp.RequestMessage
            Dart.Snmp.InformMessage

See Also

Reference

InformMessage Members
Dart.Snmp Namespace


Documentation Version 4.9
© 2016 Dart Communications. All Rights Reserved.
Send comments on this topic