EventEmitter.EventObserver
public class NarNode extends Object implements EventEmitter.EventObserver
Modifier and Type | Class | Description |
---|---|---|
class |
NarNode.EventReceivedTask |
|
static class |
NarNode.TargetNar |
Modifier and Type | Field | Description |
---|---|---|
private int |
listenPort |
|
Nar |
nar |
|
private DatagramSocket |
receiveSocket |
|
private List<NarNode.TargetNar> |
targets |
Constructor | Description |
---|---|
NarNode(int listenPort) |
Create a Nar node that listens for received tasks from other NarNode instances
|
NarNode(Nar nar,
int listenPort) |
Modifier and Type | Method | Description |
---|---|---|
void |
addRedirectionTo(String targetIP,
int targetPort,
float taskThreshold,
Term mustContainTerm,
boolean sendInput) |
Add another target Nar node to redirect tasks to, and under which conditions.
|
void |
addRedirectionTo(NarNode.TargetNar target) |
|
void |
event(Class event,
Object[] args) |
Input and derived tasks will be potentially sent
|
private Object |
receiveObject() |
NarNode's receiving a task or Narsese string
|
static void |
sendNarsese(String input,
String targetIP,
int targetPort,
float taskThreshold,
Term mustContainTerm) |
|
static void |
sendNarsese(String input,
NarNode.TargetNar target) |
Send Narsese that contains the optional mustContainTerm
|
private void |
sendTask(Task t) |
Send tasks that are above priority threshold and contain the optional mustContainTerm
|
private transient DatagramSocket receiveSocket
private int listenPort
public Nar nar
private List<NarNode.TargetNar> targets
public NarNode(int listenPort) throws SocketException, UnknownHostException, IOException, InstantiationException, InvocationTargetException, NoSuchMethodException, ParserConfigurationException, IllegalAccessException, SAXException, ClassNotFoundException, ParseException
public NarNode(Nar nar, int listenPort) throws SocketException, UnknownHostException, IOException, InstantiationException, InvocationTargetException, NoSuchMethodException, ParserConfigurationException, IllegalAccessException, SAXException, ClassNotFoundException, ParseException
public void event(Class event, Object[] args)
event
in interface EventEmitter.EventObserver
event
- args
- private void sendTask(Task t) throws IOException
t
- IOException
public static void sendNarsese(String input, NarNode.TargetNar target) throws IOException
input
- target
- IOException
public static void sendNarsese(String input, String targetIP, int targetPort, float taskThreshold, Term mustContainTerm) throws IOException
IOException
public void addRedirectionTo(String targetIP, int targetPort, float taskThreshold, Term mustContainTerm, boolean sendInput) throws SocketException, UnknownHostException
targetIP
- The target Nar node IPtargetPort
- The target Nar node porttaskThreshold
- The threshold the priority of the task has to have to redirectmustContainTerm
- The optional term that needs to be contained recursively in the task termSocketException
UnknownHostException
public void addRedirectionTo(NarNode.TargetNar target) throws SocketException, UnknownHostException
SocketException
UnknownHostException
private Object receiveObject() throws IOException
IOException
- when can't receive packetCopyright © 2020 OpenNARS. All rights reserved.