private void CreateServer() { CoAPEndPoint endpoint = new CoAPEndPoint(0); _server = new CoapServer(); // _resource = new StorageResource(TARGET, CONTENT_1); // _server.Add(_resource); Resource r2 = new EchoLocation("abc"); _server.Add(r2); r2.Add(new EchoLocation("def")); _server.AddEndPoint(endpoint); _server.Start(); _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port; Console.WriteLine($"Server port = {_serverPort}"); SecurityContextSet oscoapContexts = new SecurityContextSet(); _server.SecurityContexts.Add(SecurityContext.DeriveContext(secret, null, serverId, clientId)); _server.SecurityContexts.OscoreEvents += ServerEventHandler; }
public Task StartAsync(CancellationToken cancellationToken) { return(Task.Run(() => { server.Start(); })); }
public static void Main(String[] args) { CoapServer server = new CoapServer(); server.Add(new HelloWorldResource("hello")); server.Add(new FibonacciResource("fibonacci")); server.Add(new StorageResource("storage")); server.Add(new ImageResource("image")); server.Add(new MirrorResource("mirror")); server.Add(new LargeResource("large")); server.Add(new CarelessResource("careless")); server.Add(new SeparateResource("separate")); server.Add(new TimeResource("time")); try { server.Start(); Console.Write("CoAP server [{0}] is listening on", server.Config.Version); foreach (var item in server.EndPoints) { Console.Write(" "); Console.Write(item.LocalEndPoint); } Console.WriteLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
public void Start() { CoAP.Log.LogManager.Level = CoAP.Log.LogLevel.Error; _ProcessRequestsThread = new Thread(new ThreadStart(ProcessRequests)); if (_ProcessRequestsThread.Name == null) { _ProcessRequestsThread.Name = "ProcessRequestsThread"; } _ProcessRequestsThread.IsBackground = true; _ProcessRequestsThread.Start(); if (!SecureOnly) { _CoapServer.AddEndPoint(new CoAPEndPoint(new FlowChannel(_Port), CoapConfig.Default)); } FlowSecureChannel secure = new FlowSecureChannel(_Port + 1); if (System.IO.File.Exists("LWM2MBootsrap.pem")) { secure.CertificateFile = "LWM2MBootsrap.pem"; } secure.PSKIdentities = _PSKIdentities; secure.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8); secure.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256); secure.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256); secure.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CCM_8); secure.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256); secure.ValidatePSK += new EventHandler <ValidatePSKEventArgs>(ValidatePSK); _CoapServer.AddEndPoint(new CoAPEndPoint(secure, CoapConfig.Default)); _CoapServer.Start(); }
private static void RunInteropTests(string testToRun, ICoapConfig config, EndPoint serverEndPoint) { CoapServer server = new CoapServer(config, serverEndPoint, 5683); switch (testToRun) { case "CoapCore": InteropTests.CoapCoreTests.CoapCoreTests.Setup(server); break; default: Console.WriteLine("Interop test name not recognized"); Environment.Exit(1); break; } server.Start(); if (AsDemon) { ExitEvent.WaitOne(); } else { Console.WriteLine("Press key to exit"); Console.ReadKey(); } Environment.Exit(0); }
// public static void Main(string[] args) // { // CreateHostBuilder(args).Build().Run(); // } // public static IHostBuilder CreateHostBuilder(string[] args) => // Host.CreateDefaultBuilder(args) // .ConfigureWebHostDefaults(webBuilder => // { // webBuilder.UseStartup<Startup>(); // }); //} //Servidor COAP que recibe las peticiones de la EB public static void Main(string[] args) { var config = CargaConfiguracion(); int puerto = config.GetValue <int>("Puerto"); CoapServer server = new CoapServer(puerto); server.Add(new RecursoPeticion()); try { server.Start(); Console.Write("COAP server [{0}] is listening on", server.Config.Version); Log.Debug($"COAP server {server.Config.Version} is listening on "); foreach (var item in server.EndPoints) { Console.Write(" "); Console.Write(item.LocalEndPoint); Log.Information(item.LocalEndPoint.ToString()); } Console.WriteLine(); } catch (Exception ex) { Log.Fatal(ex.Message); } Console.WriteLine("Press any key to exit."); Console.ReadKey(); Log.CloseAndFlush(); }
public static void Main(String[] args) { CoapServer server = new CoapServer(); server.Add(new HelloWorldResource()); try { server.Start(); Console.Write("CoAP server [{0}] is listening on", server.Config.Version); foreach (var item in server.EndPoints) { Console.Write(" "); Console.Write(item.LocalEndPoint); } Console.WriteLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
private void CreateServer() { _server = new CoapServer(); CoAPEndPoint endpoint = new CoAPEndPoint(_serverPort, _config); _server.AddEndPoint(endpoint); _server.MessageDeliverer = new MessageDeliverer(this); _server.Start(); }
public void SetupServer() { Log.LogManager.Level = Log.LogLevel.Fatal; _config = new CoapConfig(); _server = new CoapServer(); CoAPEndPoint endpoint = new CoAPEndPoint(_serverPort, _config); _server.AddEndPoint(endpoint); _server.Add(new TestResource(TARGET)); _server.Start(); }
public void SetupServer() { Log.LogManager.Level = Log.LogLevel.Fatal; CoAPEndPoint endpoint = new CoAPEndPoint(); _server = new CoapServer(); _server.Add(new AccResource()); _server.Add(new NoAccResource()); _server.AddEndPoint(endpoint); _server.Start(); _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port; }
private void CreateServer() { _server = new CoapServer(); CoAPEndPoint endpoint = new CoAPEndPoint(_serverPort, _config); _server.AddEndPoint(endpoint); _server.MessageDeliverer = new MessageDeliverer(this); _server.SecurityContexts.Add(SecurityContext.DeriveContext(secret, null, serverId, clientId)); _server.Start(); _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port; }
private void CreateServer() { CoAPEndPoint endpoint = new CoAPEndPoint(0); _resource = new StorageResource(TARGET, CONTENT_1); _server = new CoapServer(); _server.Add(_resource); _server.AddEndPoint(endpoint); _server.Start(); _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port; }
private void CreateServer() { CoAPEndPoint endpoint = new DTLSEndPoint(null, UserKeys, 0); _resource = new HelloResource("Hello1"); _server = new CoapServer(); _server.Add(_resource); _server.AddEndPoint(endpoint); _server.Start(); _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port; }
public void SetupServer() { _server = new CoapServer(); CoAPEndPoint ep = new CoAPEndPoint(0); _server.AddEndPoint(ep); Resource r1 = new PubSubResource("ps", true); _server.Add(r1); _server.Start(); _port = ((System.Net.IPEndPoint)ep.LocalEndPoint).Port; }
private void CreateServer() { _server = new CoapServer(); TcpEndPoint endpoint = new TcpEndPoint(); _server.AddEndPoint(endpoint); _server.Add(new HelloWorldResource("hello")); _server.Start(); _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port; }
private void btnNext_Click(object sender, EventArgs e) { iSelectedHall = (ComboBoxItem)cmbHalls.SelectedItem; lblHall.Text = iSelectedHall.Text.ToUpper(); pnlProgress.Visible = true; pnlHallSelection.Visible = false; pnlSeatNumber.Visible = false; setInstruction(INSTR_SCAN); CoapServer server = new CoapServer(); server.Add(new LookupMatricCardResource(this)); try { server.Start(); Console.Write("CoAP server [{0}] is listening on", server.Config.Version); foreach (var item in server.EndPoints) { Console.Write(" "); Console.Write(item.LocalEndPoint); } Console.WriteLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (LOCAL) { tmrApp = new System.Windows.Forms.Timer(); tmrApp.Interval = 1000; tmrApp.Tick += new EventHandler(_delayTimer2_Elapsed); tmrApp.Start(); } else { sm132.OpenPort("COM3", 19200); tmrNfc = new System.Windows.Forms.Timer(); tmrNfc.Tick += new EventHandler(tmrNfc_Tick); tmrNfc.Enabled = true; seekTag(); } }
public static void Main(String[] args) { KeySet keys = new KeySet(); OneKey key = new OneKey(); key.Add(CoseKeyKeys.KeyType, COSE.GeneralValues.KeyType_Octet); key.Add(CoseKeyKeys.KeyIdentifier, CBORObject.FromObject(Encoding.UTF8.GetBytes("password"))); key.Add(CoseKeyParameterKeys.Octet_k, CBORObject.FromObject(Encoding.UTF8.GetBytes("sesame"))); keys.AddKey(key); CoapServer server = new CoapServer(); // server.AddEndPoint(new TcpEndPoint(5683)); server.AddEndPoint(new DTLSEndPoint(null, keys, 5684)); server.Add(new HelloWorldResource("hello")); server.Add(new FibonacciResource("fibonacci")); server.Add(new StorageResource("storage")); server.Add(new ImageResource("image")); server.Add(new MirrorResource("mirror")); server.Add(new LargeResource("large")); server.Add(new CarelessResource("careless")); server.Add(new SeparateResource("separate")); server.Add(new TimeResource("time")); try { server.Start(); Console.Write("CoAP server [{0}] is listening on", server.Config.Version); foreach (var item in server.EndPoints) { Console.Write(" "); Console.Write(item.LocalEndPoint); } Console.WriteLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("Press any key to exit."); Console.ReadKey(); server.Stop(); }
private void CreateServer() { TlsKeyPairSet allKeys = new TlsKeyPairSet(); allKeys.AddKey(X509Key); TLSEndPoint endpoint = new TLSEndPoint(allKeys, new KeySet(), 0); endpoint.TlsEventHandler += ServerTlsEvents; _resource = new TlsX509.HelloResource("Hello1"); _server = new CoapServer(); _server.Add(_resource); _server.AddEndPoint(endpoint); _server.Start(); _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port; }
private void CreateServer() { _config = new CoapConfig { NonTimeout = 10 // 10 ms }; _resource = new ObserveTests2.ObserveResource(target1); _resource2 = new ObserveTests2.ObserveResource(target2); _server = new CoapServer(_config); _server.Add(_resource); _server.Add(_resource2); IEndPoint endpoint = Pump.AddEndPoint("server #1", MockMessagePump.ServerAddress, _config, new Type[] { typeof(ObserveLayer), typeof(TokenLayer), typeof(ReliabilityLayer) }); _server.AddEndPoint(endpoint); _server.Start(); }
private void CreateServer() { CoAPEndPoint endpoint = new CoAPEndPoint(0); _resource = new TestResource(NAME_1, PAYLOAD); _server = new CoapServer(); _server .Add(new Resource(RES_A) .Add(new Resource(RES_AA) .Add(_resource .Add(new TestResource(CHILD, CHILD_PAYLOAD))))); _server.AddEndPoint(endpoint); _server.Start(); _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port; }
static void Main(string[] args) { LogManager.Instance = new FileLogManager(Console.Out); LogManager.Level = LogLevel.All; CoapServer server = new CoapServer(); PubSubResource pubsub = new PubSubResource("ps"); server.Add(pubsub); server.Start(); Console.ReadLine(); server.Stop(); }
private void CreateServer() { _config = new CoapConfig(); _config.NonTimeout = 10; // 10 ms CoAPEndPoint endpoint = new CoAPEndPoint(0, _config); _resource = new ObserveResource(target1); _resource2 = new ObserveResource(target2); _server = new CoapServer(_config); _server.Add(_resource); _server.Add(_resource2); _server.AddEndPoint(endpoint); _server.Start(); _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port; }
static void Main(string[] args) { ForwardingResource coap2coap = new ProxyCoapClientResource("coap2coap"); ForwardingResource coap2http = new ProxyHttpClientResource("coap2http"); // Create CoAP Server on PORT with proxy resources form CoAP to CoAP and HTTP CoapServer coapServer = new CoapServer(CoapConfig.Default.DefaultPort); coapServer.Add(coap2coap); coapServer.Add(coap2http); coapServer.Add(new TargetResource("target")); coapServer.Start(); ProxyHttpServer httpServer = new ProxyHttpServer(CoapConfig.Default.HttpPort); httpServer.ProxyCoapResolver = new DirectProxyCoAPResolver(coap2coap); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
private void CreateServer() { CoAPEndPoint endpoint = new CoAPEndPoint(0); _resource = new StorageResource(TARGET, CONTENT_1); _server = new CoapServer(); _server.Add(_resource); _server.AddEndPoint(endpoint); _server.Start(); _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port; Resource r2 = new EchoLocation("abc"); _server.Add(r2); r2.Add(new EchoLocation("def")); }
public static void Main(String[] args) { string ipadress = args[0]; string port = args[1]; int portInt = Int32.Parse(port); // System.Net.EndPoint endpoint= System.Net.EndPoint (ipadress, portInt); //System.Net.EndPoint endPoint = System.Net.IPAddress.Parse(ipadress); System.Net.IPAddress ip = System.Net.IPAddress.Parse(ipadress); CoapServer server = new CoapServer(); server.AddEndPoint(ip, portInt); server.Add(new HelloWorldResource("hello")); server.Add(new FibonacciResource("fibonacci")); server.Add(new StorageResource("Devices")); server.Add(new ImageResource("image")); server.Add(new MirrorResource("mirror")); server.Add(new LargeResource("large")); server.Add(new CarelessResource("careless")); server.Add(new SeparateResource("separate")); server.Add(new TimeResource("time")); try { server.Start(); Console.Write("CoAP server [{0}] is listening on", server.Config.Version); foreach (var item in server.EndPoints) { Console.Write(" "); Console.Write(item.LocalEndPoint); } Console.WriteLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
private void CreateServer() { CoAPEndPoint endpoint = new CoAPEndPoint(0); KeySet ks = new KeySet(); ks.AddKey(psk); ks.AddKey(_clientSignKey.PublicKey()); _resource = new EdhocResource(ks, serverSignKey); _server = new CoapServer(); _server.Add(_resource); _server.Add(new Hello("hello")); _server.AddEndPoint(endpoint); _server.Start(); _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port; }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { CoapServer server = new CoapServer(puerto); server.Add(new RecursoPeticion()); try { server.Start(); foreach (var item in server.EndPoints) { Log.Information($"API (CoAP Server) {server.Config.Version} is listening on {item.LocalEndPoint.ToString()}"); } } catch (Exception ex) { Log.Fatal($"ERR API//SERVIDOR CoAP - {ex.Message}"); } }
static void Main(string[] args) { CoapConfig _config = new CoapConfig(); _config.DefaultBlockSize = 32; _config.MaxMessageSize = 32; CoapServer server = new CoapServer(_config); CoAPEndPoint endpoint = new CoAPEndPoint(CoapConstants.DefaultPort, _config); server.AddEndPoint(endpoint); server.Add(new Temp("/sensors/temp")); server.Add(new Humidity("/sensors/humidity")); server.Add(new Vcc3("/sensors/vcc3")); server.Add(new Storage("/data/buffer")); server.Add(new Light("/sensors/light")); server.Add(new Hops("/info/hops")); try { server.Start(); Console.Write("CoAP server [{0}] is listening on", server.Config.Version); foreach (var item in server.EndPoints) { Console.Write(" "); Console.Write(item.LocalEndPoint); } Console.WriteLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
private void CreateServer() { CoapConfig config = new CoapConfig(); CoAPEndPoint endpoint = new CoAPEndPoint(0, config); _resource = new MulticastResource(MulticastTarget, MulticastResponse); _server = new CoapServer(); _server.Add(_resource); _server.AddEndPoint(endpoint); _server.Start(); _serverPort = ((IPEndPoint)endpoint.LocalEndPoint).Port; endpoint.AddMulticastAddress(new IPEndPoint(multicastAddress3, _serverPort)); endpoint.AddMulticastAddress(new IPEndPoint(multicastAddress4, _serverPort)); endpoint.AddMulticastAddress(new IPEndPoint(multicastAddress, _serverPort + PortJump)); endpoint.AddMulticastAddress(new IPEndPoint(multicastAddress2, _serverPort + PortJump)); Resource r2 = new UnicastResource(UnicastTarget, UnicastResponse); _server.Add(r2); }
private void CreateServer() { CoAPEndPoint endpoint = new CoAPEndPoint(0); _server = new CoapServer(); // _resource = new StorageResource(TARGET, CONTENT_1); // _server.Add(_resource); Resource r2 = new EchoLocation("abc"); _server.Add(r2); r2.Add(new EchoLocation("def")); _server.AddEndPoint(endpoint); _server.Start(); _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port; SecurityContextSet oscoapContexts = new SecurityContextSet(); SecurityContextSet.AllContexts.Add(SecurityContext.DeriveContext(_Secret, null, _ServerId, _ClientId)); }