/** * Sets the underlying message filter * * @param decoder * The new message filter to use */ public void setDecoder(NetworkMessageFilter.FilterRx decoder) { lock (this) { this.actualChannel.setDecoder(decoder); } }
private NetAltingConnectionClient(AltingChannelInput input, ChannelOutput toLink, Link link, ConnectionData connData, NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX) : base(input) { this.toLinkTX = toLink; this.In = input; this.data = connData; this.serverLocation = loc; this.localLocation = new NetConnectionLocation(Node.getInstance().getNodeID(), connData.vconnn); this.outputFilter = filterTX; this.inputFilter = filterRX; if (link != null) { this.linkConnectedTo = link; // TODO: registration stuff this.isLocal = false; this.localConnection = null; } else { this.isLocal = true; this.localConnection = ConnectionManager.getInstance().getConnection(this.serverLocation.getVConnN()); this.linkConnectedTo = null; } }
/** * A static factory method to create a new Net2AnyChannel object * * @param poisonImmunity * The immunity level of the channel * @param filter * The filter used to convert an incoming byte array into an object * @return A new Net2AnyChannel * @//throws JCSPNetworkException * Thrown if there is a problem creating the underlying channel */ internal static Net2AnyChannel create(int poisonImmunity, NetworkMessageFilter.FilterRx filter) ////throws JCSPNetworkException { // Create the underlying channel Net2OneChannel chan = Net2OneChannel.create(poisonImmunity, filter); // Return a new instance of this object return(new Net2AnyChannel(chan)); }
private NetAltingConnectionServer(AltingChannelInput openChan, AltingChannelInput requestChan, ConnectionData connData, NetworkMessageFilter.FilterRx filterRX, NetworkMessageFilter.FilterTx filterTX) : base(openChan) ////throws JCSPNetworkException { this.openIn = openChan; this.requestIn = requestChan; this.data = connData; this.inputFilter = filterRX; this.outputFilter = filterTX; this.location = new NetConnectionLocation(Node.getInstance().getNodeID(), this.data.vconnn); }
static NetAltingConnectionServer create(NetworkMessageFilter.FilterRx filterRX, NetworkMessageFilter.FilterTx filterTX) { ConnectionData data = new ConnectionData(); Any2OneChannel requestChan = Channel.any2one(new InfiniteBuffer()); Any2OneChannel openChan = Channel.any2one(new InfiniteBuffer()); data.toConnection = requestChan.Out(); data.openServer = openChan.Out(); data.state = ConnectionDataState.SERVER_STATE_CLOSED; ConnectionManager.getInstance().create(data); return(new NetAltingConnectionServer(openChan.In(), requestChan.In(), data, filterRX, filterTX)); }
/** * Private constructor for creating a new instance of a Net2OneChannel. This is called by the create method to * create the channel. * * @param input * The input channel connecting to the networked channel. * @param chanData * The ChannelData object representing the networked channel. * @param filter * The filter used to convert the incoming byte array to an object * @//throws JCSPNetworkException */ private Net2OneChannel(AltingChannelInput input, ChannelData chanData, NetworkMessageFilter.FilterRx filter) : base(input) //throws JCSPNetworkException { // Set the wrapper's alting channel input so the channel can be used as a guard // Set the various properties this.In = input; this.data = chanData; this.data.state = ChannelDataState.OK_INPUT; this.location = new NetChannelLocation(Node.getInstance().getNodeID(), this.data.vcn); this.messageFilter = filter; }
/** * Static factory method used to create a new Net2OneChannel. Used internally within the architecture. * * @param poisonImmunity * The immunity level of the channel * @param filter * The filter on the channel used to convert read bytes into an object * @return A new Net2OneChannel */ public static Net2OneChannel create(int poisonImmunity, NetworkMessageFilter.FilterRx filter) { // Create a new ChannelData object ChannelData data = new ChannelData(); // Create a new infinitely buffered any2one channel connecting the Links to the channel object Any2OneChannel chan = Channel.any2one(new InfiniteBuffer()); // Add the output end to the ChannelData object data.toChannel = chan.Out(); // Set the immunity level data.immunityLevel = poisonImmunity; // Initialise the ChannelData object with the ChannelManager ChannelManager.getInstance().create(data); // Return a new Net2OneChannel return(new Net2OneChannel(chan.In(), data, filter)); }
/** * Static factory method for creating a new instance of Net2AnyChannel, given a particular index * * @param index * The index to create the channel with * @param poisonImmunity * the immunity level of the channels * @param filter * The filter used to convert the byte array back into an object * @return A new Net2AnyChannel * @//throws ArgumentException * Thrown if a channel with the given index already exists * @//throws JCSPNetworkException * Thrown if something goes wrong during the creation of the underlying channel */ internal static Net2AnyChannel create(int index, int poisonImmunity, NetworkMessageFilter.FilterRx filter) { // Create the underlying channel Net2OneChannel chan = null; try { chan = Net2OneChannel.create(index, poisonImmunity, filter); } catch (ArgumentException e) { Console.WriteLine(e); } catch (JCSPNetworkException e) { Console.WriteLine(e); } // Return a new instance of Net2AnyChannel return(new Net2AnyChannel(chan)); }
/** * Creates a new NetSharedChannelInput with the given index and poison immunity level, which uses the given filter * to decode incoming messages. * * @param index * The index to create the channel with * @param immunityLevel * The immunity level to poison that the channel has * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput * @//throws ArgumentException * Thrown if a channel with the given index already exists. */ public static NetSharedChannelInput numberedNet2Any(int index, int immunityLevel, NetworkMessageFilter.FilterRx filter) //throws ArgumentException { return(factory.numberedNet2Any(index, immunityLevel, filter)); }
/** * Creates a new NetAltingChannelInput with the given index and given poison immunity, which uses the given filter * to decode incoming messages * * @param index * The index to create the channel with * @param immunityLevel * The immunity to poison that the channel has * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput * @//throws ArgumentException * Thrown if a channel with the given index already exists */ public NetAltingChannelInput numberedNet2One(int index, int immunityLevel, NetworkMessageFilter.FilterRx filter) ////throws ArgumentException { return(Net2OneChannel.create(index, immunityLevel, filter)); }
/** * Creates a new NetSharedChannelInput with the given poison immunity level, which uses the given filter to decode * messages * * @param immunityLevel * The immunity level to poison for this channel * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput */ public static NetSharedChannelInput net2any(int immunityLevel, NetworkMessageFilter.FilterRx filter) { return(factory.net2any(immunityLevel, filter)); }
/** * Creates a new NetAltingChannelInput with the given index that uses the given filter to decode incoming messages * * @param index * The index to create the channel with * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput * @//throws ArgumentException * Thrown if a channel with the given index already exists */ public static NetAltingChannelInput numberedNet2One(int index, NetworkMessageFilter.FilterRx filter) //throws ArgumentException { return(factory.numberedNet2One(index, filter)); }
/** * Creates a new NetAltingChannelInput with the given poison immunity level which uses the given filter to decode * incoming messages * * @param immunityLevel * The immunity level to poison for the created channel * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput */ public static NetAltingChannelInput net2one(int immunityLevel, NetworkMessageFilter.FilterRx filter) { return(factory.net2one(immunityLevel, filter)); }
/** * Creates a new NetSharedChannelInput which uses the given filter to decode incoming messages * * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput */ public static NetSharedChannelInput net2any(NetworkMessageFilter.FilterRx filter) { return(factory.net2any(filter)); }
public abstract void setDecoder(NetworkMessageFilter.FilterRx decoder);
/** * Creates a new NetAltingChannelInput which uses the given filter to decode incoming messages * * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput */ public static NetAltingChannelInput net2one(NetworkMessageFilter.FilterRx filter) { return(factory.net2one(filter)); }
/** * Sets the underlying message filter * * @param decoder * The message filter to use */ public override void setDecoder(NetworkMessageFilter.FilterRx decoder) { this.messageFilter = decoder; }
/** * Creates a new NetAltingChannelInput which uses the given filter to decode incoming messages * * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput */ public NetAltingChannelInput net2one(NetworkMessageFilter.FilterRx filter) { return(Net2OneChannel.create(Int32.MaxValue, filter)); }
/** * Creates a new NetAltingChannelInput with the given poison immunity level which uses the given filter to decode * incoming messages * * @param immunityLevel * The immunity level to poison for the created channel * @param filter * The filter used to decode incoming messages * @return A new NetAltingChannelInput */ public NetAltingChannelInput net2one(int immunityLevel, NetworkMessageFilter.FilterRx filter) { return(Net2OneChannel.create(immunityLevel, filter)); }
/** * Creates a new NetSharedChannelInput with the given poison immunity level, which uses the given filter to decode * messages * * @param immunityLevel * The immunity level to poison for this channel * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput */ public NetSharedChannelInput net2any(int immunityLevel, NetworkMessageFilter.FilterRx filter) { return(Net2AnyChannel.create(immunityLevel, filter)); }
/** * Creates a new NetSharedChannelInput which uses the given filter to decode incoming messages * * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput */ public NetSharedChannelInput net2any(NetworkMessageFilter.FilterRx filter) { return(Net2AnyChannel.create(Int32.MaxValue, filter)); }
/** * Creates a new NetSharedChannelInput with the given index that uses the given filter to decode incoming messages * * @param index * The index to create the channel with * @param filter * The filter used to decode incoming messages * @return A new NetSharedChannelInput * @//throws ArgumentException * Thrown if a channel with the given index already exists */ public NetSharedChannelInput numberedNet2Any(int index, NetworkMessageFilter.FilterRx filter) ////throws ArgumentException { return(Net2AnyChannel.create(index, Int32.MaxValue, filter)); }
static NetAltingConnectionClient create(NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX) ////throws JCSPNetworkException { // Create the connection data structure ConnectionData data = new ConnectionData(); // Create channel linking this to the Link level. This channel is used to receive response and // acknowledgement messages Any2OneChannel chan = Channel.any2one(new InfiniteBuffer()); data.toConnection = chan.Out(); // Set state of connection data.state = ConnectionDataState.CLIENT_STATE_CLOSED; ConnectionManager.getInstance().create(data); ChannelOutput toLink; if (loc.getNodeID().equals(Node.getInstance().getNodeID())) { toLink = ConnectionManager.getInstance().getConnection(loc.getVConnN()).toConnection; return(new NetAltingConnectionClient(chan.In(), toLink, null, data, loc, filterTX, filterRX)); } Link link = LinkManager.getInstance().requestLink(loc.getNodeID()); if (link == null) { link = LinkFactory.getLink(loc.getNodeID()); } toLink = link.getTxChannel(); return(new NetAltingConnectionClient(chan.In(), toLink, link, data, loc, filterTX, filterRX)); }