public Task StopAsync(CancellationToken cancellationToken) { return(Task.Run(() => { server.Stop(); })); }
public void KillServer() { if (_server != null) { _server.Stop(); } }
public void Stop() { _Terminate = true; _TriggerProcessRequests.Set(); _CoapServer.Stop(); BusinessLogicFactory.Clients.Stop(); _ProcessRequestsThread.Join(); _ProcessRequestsThread = null; }
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(); }
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(); }
public void Stop() { _Terminate = true; if (_ServiceHost != null) { _ServiceHost.Close(); _ServiceHost = null; } if (_NativeServerAPI != null) { _NativeServerAPI.Stop(); } if (_NativeServerAPIv6 != null) { _NativeServerAPIv6.Stop(); } _TriggerProcessRequests.Set(); _CoapServer.Stop(); _ProcessRequestsThread.Join(); _ProcessRequestsThread = null; }
public void TeardownServer() { _server.Stop(); _server.Dispose(); _server = null; }
public void Stop() { _Timer.Stop(); Disconnect(); _CoapServer.Stop(); }
public Task StopAsync(CancellationToken cancellationToken) { server.Stop(); return(Task.CompletedTask); }
static void Main(string[] args) { ICoapConfig config = null; KeySet allKeys = null; string interopTest = null; LogManager.Level = LogLevel.All; LogManager.Instance = new FileLogManager(Console.Out); for (int i = 0; i < args.Length; i++) { String[] s = args[i].Split('='); if (s.Length == 1) { Array.Resize(ref s, 2); } switch (s[0]) { case "--generate": GenerateKeys(s[1]); break; case "--loadkeys": allKeys = LoadKeys(s[1]); break; case "--config": if (s[1] == null) { PrintCommandLine(); } config = new CoapConfig(); config.Load(s[1]); break; case "--demon": AsDemon = true; break; case "--ipAddr": case "--ipaddress": if (s[1] == null) { PrintCommandLine(); } IPAddress ip; if (!IPAddress.TryParse(s[1], out ip)) { Console.WriteLine("Invalid ip-address"); PrintCommandLine(); } ServerEndPoint = new IPEndPoint(ip, 0); break; case "--interop-test": if (s[1] == null) { PrintCommandLine(); } interopTest = s[1]; break; default: PrintCommandLine(); break; } } if (interopTest != null) { RunInteropTests(interopTest, config, ServerEndPoint); } if (allKeys == null) { allKeys = LoadKeys(null); } CoapServer server1 = SetupServer(config, ServerEndPoint, CoapConfig.Default.DefaultPort, DtlsSignKeys, DtlsValidateKeys); CoapServer server2 = SetupServer(config, ServerEndPoint, 5685, DtlsSignKeys, DtlsValidateKeys); if (AsDemon) { ExitEvent.WaitOne(); } else { Console.WriteLine("Press key to exit"); Console.ReadKey(); } server1.Stop(); server2.Stop(); }