Dart.Snmp Namespace : GetNextMessage Class |
<SerializableAttribute()> Public Class GetNextMessage Inherits RequestMessage
Dim instance As GetNextMessage
[Serializable()] public class GetNextMessage : RequestMessage
[Serializable()] public __gc class GetNextMessage : public RequestMessage
[Serializable()] public ref class GetNextMessage : public RequestMessage
Specializes RequestMessage. Used by an SNMP manager to request information from an SNMP agent while discovering what IIDs are being managed. The agent will typically respond by constructing and sending the manager a ResponseMessage that contains the next IID it manages (in lexicographical order) and its value. Multiple ID "fragments" may be requested, with the manager expecting a ResponseMessage containing the next IID for each ID fragment specified.
For example, using an ID fragment of "1" in GetNextMessage might return an IID of "1.3.6.1.2.1.1.1.0" in the ResponseMessage, indicating that this is the first IID managed by the agent.
Serializable using BinaryFormatter and XmlSerializer.
private void button1_Click(object sender, EventArgs e) { //Create and send request on a worker thread manager1.Start(sendRequests, manager1.Mib.CreateVariable(NodeName.sysContact)); } private void sendRequests(SnmpSocket managerSocket, object state) { //Create GetNext Request GetNextMessage request1 = new GetNextMessage(); request1.Variables.Add(state as Variable); //Send request and get response //Response will include the next supported OID, which should be sysName. ResponseMessage response1 = managerSocket.GetResponse(request1, myAgentAddress); //Get the next supported OID after the one just received, which should be sysLocation. //Use the previous response to set the request variable for this GetNextMessage. GetNextMessage request2 = new GetNextMessage(); request2.Variables.Add(response1.Variables[0]); ResponseMessage response2 = managerSocket.GetResponse(request2, myAgentAddress); //This process could be continued here to walk all values on the agent //Marshal messages to the UI thread using the Message event manager1.Marshal(new ResponseMessage[] { response1, response2 }, "", null); } private void manager1_Message(object sender, Dart.Snmp.MessageEventArgs e) { //Fires on the UI thread //Display info about the first variable of each response, and its value Variable varSysContact = e.Messages[0].Variables[0]; Variable varSysName = e.Messages[1].Variables[0]; label1.Text = varSysContact.Definition.ToString() + "\r\nValue: " + varSysContact.Value.ToString(); label2.Text = varSysName.Definition.ToString() + "\r\nValue: " + varSysName.Value.ToString(); }
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) 'Create and send request on a worker thread manager1.Start(AddressOf sendRequests, manager1.Mib.CreateVariable(NodeName.sysContact)) End Sub Private Sub sendRequests(ByVal managerSocket As SnmpSocket, ByVal state As Object) 'Create GetNext Request Dim request1 As New GetNextMessage() request1.Variables.Add(TryCast(state, Variable)) 'Send request and get response 'Response will include the next supported OID, which should be sysName. Dim response1 As ResponseMessage = managerSocket.GetResponse(request1, myAgentAddress) 'Get the next supported OID after the one just received, which should be sysLocation. 'Use the previous response to set the request variable for this GetNextMessage. Dim request2 As New GetNextMessage() request2.Variables.Add(response1.Variables(0)) Dim response2 As ResponseMessage = managerSocket.GetResponse(request2, myAgentAddress) 'This process could be continued here to walk all values on the agent 'Marshal messages to the UI thread using the Message event manager1.Marshal(New ResponseMessage() { response1, response2 }, "", Nothing) End Sub Private Sub manager1_Message(ByVal sender As Object, ByVal e As Dart.Snmp.MessageEventArgs) 'Fires on the UI thread 'Display info about the first variable of each response, and its value Dim varSysContact As Variable = e.Messages(0).Variables(0) Dim varSysName As Variable = e.Messages(1).Variables(0) label1.Text = varSysContact.Definition.ToString() & vbCrLf & "Value: " & varSysContact.Value.ToString() label2.Text = varSysName.Definition.ToString() & vbCrLf & "Value: " & varSysName.Value.ToString() End Sub
System.Object
Dart.Snmp.MessageBase
Dart.Snmp.StandardMessage
Dart.Snmp.RequestMessage
Dart.Snmp.GetNextMessage