| Dart.PowerSNMP Namespace > Agent Class : SetMessageReceived Event |
Occurs when an SNMP set request is received.
[Visual Basic]
<CategoryAttribute("Request")>
<DescriptionAttribute("Raised when a SetMessage is received from an SNMP manager.")>
Public Event SetMessageReceived() As MessageEventHandler[C#]
[CategoryAttribute("Request")]
[DescriptionAttribute("Raised when a SetMessage is received from an SNMP manager.")]
public event MessageEventHandler SetMessageReceived();[C++]
[CategoryAttribute("Request")]
[DescriptionAttribute("Raised when a SetMessage is received from an SNMP manager.")]
public: __event MessageEventHandler* SetMessageReceived();[C++/CLI]
[CategoryAttribute("Request")]
[DescriptionAttribute("Raised when a SetMessage is received from an SNMP manager.")]
public:
event MessageEventHandler^ SetMessageReceived();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 SetMessage has been received. This message provides an atomic mechanism for setting 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 Set message.
[Visual Basic]
Private Sub Agent1_SetMessageReceived(ByVal sender As Object, ByVal e As Dart.PowerSNMP.MessageEventArgs) Handles Agent1.SetMessageReceived
'add SetMessage variables to a listbox
Dim msg As SetMessage = 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_SetMessageReceived(Dart.PowerSNMP.MessageEventArgs e)
{
// add SetMessage variables to a listbox
SetMessage msg = e.Request as SetMessage;
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.