| Dart.PowerSNMP Namespace > Agent Class : GetMessageReceived Event |
Occurs when an SNMP get request is received.
[Visual Basic]
<CategoryAttribute("Request")>
<DescriptionAttribute("Raised when a GetMessage is received from an SNMP manager.")>
Public Event GetMessageReceived() As MessageEventHandler[C#]
[CategoryAttribute("Request")]
[DescriptionAttribute("Raised when a GetMessage is received from an SNMP manager.")]
public event MessageEventHandler GetMessageReceived();[C++]
[CategoryAttribute("Request")]
[DescriptionAttribute("Raised when a GetMessage is received from an SNMP manager.")]
public: __event MessageEventHandler* GetMessageReceived();[C++/CLI]
[CategoryAttribute("Request")]
[DescriptionAttribute("Raised when a GetMessage is received from an SNMP manager.")]
public:
event MessageEventHandler^ GetMessageReceived();The event handler receives an argument of type MessageEventArgs containing data related to this event. The following MessageEventArgs properties provide information specific to this event.
| Property | Description |
|---|---|
| Request | Gets the RequestMessage received or previously sent. |
| Response | Gets or sets the ResponseMessage received or to be sent. |
A GetMessage has been received. This message provides an atomic mechanism for getting the values of IIDs.
If Agent.Variables is null, then MessageEventArgs.Response.Variables is not populated. In this case the application should either add variables to complete the response for the library to send or set MessageEventArgs.Response to null to indicate no response should be sent.
If Agent.Variables is not null, then the library will construct a default ResponseMessage. An error ResponseMessage is constructed if requested IIDs are not present.
Most agent applications will take advantage of Agent.Variables by populating it with Variable objects so that default response messages are generated.
The ResponseMessage(RequestMessage, SortedVariables) constructor is used to generate MessageEventArgs.Response.
If no ResponseMessage is sent then some SNMP managers will repeat the request.
The following example demonstrates handling a Get message.
[Visual Basic]
Private Sub Agent1_GetMessageReceived(ByVal sender As Object, ByVal e As Dart.PowerSNMP.MessageEventArgs) Handles Agent1.GetMessageReceived
'add GetMessage variables to a listbox
Dim msg As GetMessage = e.Request
Dim v As Variable
For Each v In msg.Variables
ListBox1.Items.Add(v.Id + ": " + v.Value.ToString())
Next
End Sub
[C#]
private void agent1_GetMessageReceived(Dart.PowerSNMP.MessageEventArgs e)
{
// add GetMessage variables to a listbox
GetMessage msg = e.Request as GetMessage;
foreach (Variable v in msg.Variables)
listBox1.Items.Add(v.Id + ": " + v.Value.ToString());
}
Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista
Send comments on this topic.
Documentation version 1.2.0.0.
© 2008 Dart Communications. All rights reserved.