A RequestAgent is a ServiceAgent that implements RequestAgentInterface. Create agents that extend this class to inherit the basic functionality for registering them with the ServiceManager at startup and making it available to other agents as a request based service.
RequestAgents are commonly used in conjunction with the WebServer and SecureWebServer classes to respond to HTTP requests. Here's an example of a simple RequestAgent written in Visual Basic:
Imports com.neokernel.nk
Imports com.neokernel.util
Public Class SimpleVBPage
Inherits RequestAgent
Overrides Sub handleRequest(ByVal Request As AgentRequest)
Dim title, body As String
body = getString("body")
Request.println(body)
End Sub
Overrides Sub initProps()
setDefault("service_name", "/simple.agent")
setDefault("body", "This is output from the SimplePage agent!")
End Sub
End Class
If a browser requests http://localhost/simple.agent from a server that has started the above SimpleAgent, the browser will display the text
This is output from the SimplePage agent!
Here is the exact same agent written using C#:
using System;
using com.neokernel.nk;
public class SimplePage : RequestAgent
{
public override void initProps()
{
setDefault("service_name", "/simple.agent");
setDefault("body", "This is output from the SimplePage agent!");
}
public override void handleRequest(HTTPAgentRequest request)
{
String body = getString("body");
request.println( body );
}
}
For a list of all members of this type, see RequestAgent Members .
System.Object
Props
Agent
ServiceAgent
RequestAgent
Derived types
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
Namespace: com.neokernel.nk
Assembly: Neokernel (in Neokernel.exe)
RequestAgent Members | com.neokernel.nk Namespace | AgentRequest | HTTPAuthenticationAgent | HTTPFileServerAgent | HTTPProxyAgent | HTTPAuthenticationAgent | WebServer