public abstract class

Protocol

extends Object
implements InputHandler
java.lang.Object
   ↳ uk.ac.imperial.presage2.util.protocols.Protocol
Known Direct Subclasses

Class Overview

An InputHandler which manages a set of Conversations which produce and consume Messages of this protocol. The handler will be able to handle messages whose protocol name matches the name field of this object.

The protocol keeps a list of active Conversations of this protocol. When a new Message of this protocol arrives it hands it to any of these active conversations who can handle it. If none can handle we spawn(Message) a new conversation from the message.

The protocol can also be used to spawn new active conversations with 0, 1 or many NetworkAddresses provided.

Summary

Fields
protected List<Conversation> activeConversations
protected final String name
Protected Constructors
Protocol(String name)
Public Methods
boolean canHandle(Input in)
Check if this Handler can handle the given Input
Set<NetworkAddress> getActiveConversationMembers()
Get the set of NetworkAddresses involved in an active conversation with us in this protocol.
Set<Conversation> getActiveConversations()
Get the set of active conversations managed by this protocol.
void handle(Input in)
Handle the given Input.
abstract void incrementTime(int t)
abstract Conversation spawn()
Spawn a conversation of this protocol.
abstract Conversation spawn(Set<NetworkAddress> with)
Spawn a conversation of this protocol with the given network addresses (multi-cast conversation).
abstract void spawn(Message m)
Spawn a conversation of this protocol from the given input message (reactive conversation).
abstract Conversation spawn(NetworkAddress with)
Spawn a conversation of this protocol with the given network address.
[Expand]
Inherited Methods
From class java.lang.Object
From interface uk.ac.imperial.presage2.core.messaging.InputHandler

Fields

protected List<Conversation> activeConversations

protected final String name

Protected Constructors

protected Protocol (String name)

Public Methods

public boolean canHandle (Input in)

Check if this Handler can handle the given Input

Parameters
in Input to handle
Returns
  • true if it can, false otherwise.

public Set<NetworkAddress> getActiveConversationMembers ()

Get the set of NetworkAddresses involved in an active conversation with us in this protocol.

public Set<Conversation> getActiveConversations ()

Get the set of active conversations managed by this protocol.

public void handle (Input in)

Handle the given Input.

Parameters
in Input to handle.

public abstract void incrementTime (int t)

public abstract Conversation spawn ()

Spawn a conversation of this protocol. No arguments are provided so this will usually be a broadcast conversation.

public abstract Conversation spawn (Set<NetworkAddress> with)

Spawn a conversation of this protocol with the given network addresses (multi-cast conversation).

public abstract void spawn (Message m)

Spawn a conversation of this protocol from the given input message (reactive conversation).

public abstract Conversation spawn (NetworkAddress with)

Spawn a conversation of this protocol with the given network address.