/** * Instantiates a new endpoint with the specified connector and * configuration. * * @param connector the connector * @param config the config */ public CoapEndpoint(Connector connector, NetworkConfig config) { this.config = config; this.connector = connector; this.serializer = new Serializer(); this.matcher = new Matcher(config); this.coapstack = new CoapStack(config, new OutboxImpl()); this.connector.setRawDataReceiver(new InboxImpl()); }
/** * Creates a new endpoint for a connector, configuration and message exchange store. * * @param connector the connector * @param config the config * @param exchangeStore the store to use for keeping track of message exchanges. */ public CoapEndpoint(final Connector connector, final NetworkConfig config, final MessageExchangeStore exchangeStore) { this.config = config; this.connector = connector; this.connector.setRawDataReceiver(new InboxImpl()); MessageExchangeStore localExchangeStore = (null != exchangeStore) ? exchangeStore : new InMemoryMessageExchangeStore(config); // To make TCP support backwards compatible using less clean "instanceof" shortcut in 1.1 branch. // In 2.0 branch, the connector API has been expected to export a new isSchemeSupported(String scheme) // method, which is used instead. if (connector instanceof TcpConnector) { this.matcher = new TcpMatcher(config, localExchangeStore); this.coapstack = new CoapTcpStack(config, new OutboxImpl()); this.serializer = new TcpDataSerializer(); this.parser = new TcpDataParser(); } else { this.matcher = new UdpMatcher(config, localExchangeStore); this.coapstack = new CoapUdpStack(config, new OutboxImpl()); this.serializer = new UdpDataSerializer(); this.parser = new UdpDataParser(); } }