当前位置: 首页>>代码示例>>Java>>正文


Java NetworkConfig.createStandardWithoutFile方法代码示例

本文整理汇总了Java中org.eclipse.californium.core.network.config.NetworkConfig.createStandardWithoutFile方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkConfig.createStandardWithoutFile方法的具体用法?Java NetworkConfig.createStandardWithoutFile怎么用?Java NetworkConfig.createStandardWithoutFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.californium.core.network.config.NetworkConfig的用法示例。


在下文中一共展示了NetworkConfig.createStandardWithoutFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.eclipse.californium.core.network.config.NetworkConfig; //导入方法依赖的package包/类
public List<Stage.ConfigIssue> init(Stage.Context context) {
  List<Stage.ConfigIssue> issues = new ArrayList<>();
  NetworkConfig networkConfig = NetworkConfig.createStandardWithoutFile();
  networkConfig.set(NetworkConfig.Keys.DEDUPLICATOR, NetworkConfig.Keys.NO_DEDUPLICATOR);
  networkConfig.set(NetworkConfig.Keys.PROTOCOL_STAGE_THREAD_COUNT, coAPServerConfigs.maxConcurrentRequests);
  networkConfig.set(NetworkConfig.Keys.NETWORK_STAGE_RECEIVER_THREAD_COUNT, coAPServerConfigs.maxConcurrentRequests);
  if (coAPServerConfigs.networkConfigs != null) {
    for (String key: coAPServerConfigs.networkConfigs.keySet()) {
      networkConfig.set(key, coAPServerConfigs.networkConfigs.get(key));
    }
  }
  coapServer = new CoapServer(networkConfig, coAPServerConfigs.port);
  coapReceiverResource = new CoapReceiverResource(context, receiver, errorQueue);
  coapServer.add(coapReceiverResource);
  coapServer.start();
  return issues;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:18,代码来源:CoapReceiverServer.java

示例2: setUp

import org.eclipse.californium.core.network.config.NetworkConfig; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  int port =  TestHttpClientTarget.getFreePort();
  coapServer = new CoapServer(NetworkConfig.createStandardWithoutFile(), port);
  coapServer.add(new CoapResource("test") {
    @Override
    public void handlePOST(CoapExchange exchange) {
      serverRequested = true;
      if (returnErrorResponse) {
        exchange.respond(CoAP.ResponseCode.INTERNAL_SERVER_ERROR);
        return;
      }
      requestPayload = new String(exchange.getRequestPayload());
      exchange.respond(CoAP.ResponseCode.VALID);
    }
  });
  resourceURl = "coap://localhost:" + port + "/test";
  coapServer.start();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:20,代码来源:TestCoapClientTarget.java

示例3: testCoapComponent

import org.eclipse.californium.core.network.config.NetworkConfig; //导入方法依赖的package包/类
@Test
public void testCoapComponent() throws Exception {
    NetworkConfig.createStandardWithoutFile();

    String coapConsumerUri = String.format("coap://localhost:%d/hello", AvailablePortFinder.getNextAvailable());

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            fromF(coapConsumerUri)
            .convertBodyTo(String.class)
            .setBody(simple("Hello ${body}"));
        }
    });

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        String result = template.requestBody(coapConsumerUri + "?coapMethod=POST", "Kermit", String.class);
        Assert.assertEquals("Hello Kermit", result);
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:26,代码来源:CoapIntegrationTest.java

示例4: testCoAP

import org.eclipse.californium.core.network.config.NetworkConfig; //导入方法依赖的package包/类
@Test
public void testCoAP() throws Exception {
    NetworkConfig.createStandardWithoutFile();
    CoapClient client = new CoapClient("coap://localhost:" + PORT + "/TestResource");
    CoapResponse rsp = client.get();
    assertEquals("Hello ", rsp.getResponseText());
    
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);
    mock.expectedBodiesReceived("Hello");
    sender.sendBody("Hello");
    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:CoAPComponentTest.java

示例5: connectionOpen

import org.eclipse.californium.core.network.config.NetworkConfig; //导入方法依赖的package包/类
/**
 * init the connection to the gateway
 * @param gatewayIP IP or DNS of the gateway
 * @param gatewaySecret Secret, is on the bottom label on the gateway
 * @param configFile path to a Properties-File that is writeable, can be null (than a new file in the current directory will be created)
 */
public void connectionOpen(String gatewayIP, String gatewaySecret, Integer udpPort) {
	this.gatewayIP = gatewayIP;
	this.gatewaySecret = gatewaySecret;
	this.udpPort = udpPort;
	
	String connectionSecret = "", connectionIdentity = "";
	Map<String, String> connectionParams = this.getIdentityInformation(this.gatewaySecret);
	
	connectionSecret = connectionParams.get("psk");
	connectionIdentity = connectionParams.get("identity");
	
	try {
		// load key store
		KeyStore keyStore = KeyStore.getInstance("JKS");
		InputStream in = getClass().getClassLoader().getResourceAsStream(KEY_STORE_LOCATION);
		keyStore.load(in, KEY_STORE_PASSWORD.toCharArray());
		in.close();

		// load trust store
		KeyStore trustStore = KeyStore.getInstance("JKS");
		in = getClass().getClassLoader().getResourceAsStream(TRUST_STORE_LOCATION);
		trustStore.load(in, TRUST_STORE_PASSWORD.toCharArray());
		in.close();

		// You can load multiple certificates if needed
		Certificate[] trustedCertificates = new Certificate[1];
		trustedCertificates[0] = trustStore.getCertificate("root");

		DtlsConnectorConfig.Builder builder = new DtlsConnectorConfig.Builder();
		builder.setAddress(new InetSocketAddress(this.udpPort));
		builder.setPskStore(new StaticPskStore(connectionIdentity, connectionSecret.getBytes()));
		builder.setIdentity((PrivateKey)keyStore.getKey("client", KEY_STORE_PASSWORD.toCharArray()),
				keyStore.getCertificateChain("client"), true);
		builder.setTrustStore(trustedCertificates);
		
		//try to fix timeouts at user
		builder.setRetransmissionTimeout(50000);
		
		dtlsConnector = new DTLSConnector(builder.build());
		
	} catch (Exception e) {
		System.err.println("[GWConnection] Error while initializing key store: ");
		e.printStackTrace();
		System.exit(-1);
	}
	
	//custom network config without a config file
	NetworkConfig networkConfig = NetworkConfig.createStandardWithoutFile();
	networkConfig.set(Keys.ACK_TIMEOUT, 40000);
	networkConfig.setInt(Keys.MAX_RESOURCE_BODY_SIZE, 8192);
	NetworkConfig.setStandard(networkConfig);
	
	client = new CoapClient();
	
	client.setEndpoint(new CoapEndpoint(dtlsConnector, networkConfig));
	client.setTimeout(60000);
	
	//client.setEndpoint(new CoapEndpoint(dtlsConnector, NetworkConfig.getStandard()));
	
	//after opening connection: fetch well known
	System.out.println("[GWConnection] Fetching well-known...");
	System.out.println("[GWConnection] " + this.get("/.well-known/core").getResponseText());
}
 
开发者ID:peterkappelt,项目名称:JTradfri,代码行数:70,代码来源:GWConnection.java


注:本文中的org.eclipse.californium.core.network.config.NetworkConfig.createStandardWithoutFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。