private void OnShutdownMessage(IPeer peer, ShutdownMessage message) { var channel = _channelService.Channels.SingleOrDefault(c => c.ChannelId == message.ChannelId.ToHex()); if (channel == null) { _logger.LogDebug($"Remote sent us a {nameof(ShutdownMessage)}, but there is no matching channel."); peer.Messaging.Send(ErrorMessage.UnknownChannel(message.ChannelId)); return; } if (channel.RemoteChannelParameters.ShutdownScriptPubKey != null && !channel.RemoteChannelParameters.ShutdownScriptPubKey.SequenceEqual(message.ScriptPubKey)) { _channelLoggingService.LogError(channel, LocalChannelError.InvalidShutdownScriptPubKey, "Received shutdown message with invalid ShutdownScriptPubKey. Will do an unilateral close"); channel.CloseReason = CloseReason.InvalidShutdownPubKey; UnilateralClose(channel); return; } channel.RemoteChannelParameters.ShutdownScriptPubKey = message.ScriptPubKey; if (channel.State == LocalChannelState.NormalOperation) { channel.CloseReason = CloseReason.RemoteMutualClose; RespondWithShutdown(peer, channel, message); } else if (channel.State == LocalChannelState.Shutdown || channel.State == LocalChannelState.ClosingSigned) { RespondWithClosingSigned(peer, channel); } _channelService.UpdateChannel(channel); }
private void OnServerShutdown(ShutdownMessage msg) { _messageWindow.Title.text = "Shutdown In Progress"; _messageWindow.Message.text = "Server has issued a shutdown."; _messageWindow.gameObject.SetActive(true); NetworkClient.Disconnect(); }
private void RespondWithShutdown(IPeer peer, LocalChannel channel, ShutdownMessage message) { ShutdownMessage shutdownMessage = new ShutdownMessage(); shutdownMessage.ScriptPubKey = channel.LocalChannelParameters.ShutdownScriptPubKey; shutdownMessage.ChannelId = channel.ChannelId.HexToByteArray(); peer.Messaging.Send(shutdownMessage); }
private void SendShutdownMessage(LocalChannel channel, IPeer peer) { ShutdownMessage shutdownMessage = new ShutdownMessage(); shutdownMessage.ChannelId = channel.ChannelId.HexToByteArray(); shutdownMessage.ScriptPubKey = _walletService.PubKeyAddress.ScriptPubKey.ToBytes(); //channel.FinalPubKeyScript; peer.Messaging.Send(shutdownMessage); }
private void Dispose(bool disposing) { if (disposing) { if (!_stopped.GetAndSet(true)) { _flushTimer.Dispose(); if (_flushUsersTimer != null) { _flushUsersTimer.Dispose(); } SubmitMessage(new FlushMessage()); ShutdownMessage message = new ShutdownMessage(); SubmitMessage(message); message.WaitForCompletion(); ((IDisposable)_dispatcher).Dispose(); _messageQueue.CompleteAdding(); _messageQueue.Dispose(); } } }
private void handleShutDownMessage(ShutdownMessage msg) { Application.Current.Shutdown(); }
/// <summary> /// Entry point for the application /// </summary> /// <param name="args"></param> public static void Main(string[] args) { // Create the message pool MessagePool pool = new MessagePool(); // Create the root actor Actor root = new Actor(pool); // Attach core systems root.AddComponent<UserInputHandler>(); root.AddComponent<Renderer>(); root.AddComponent<MaterialSystem>(); root.AddComponent<SceneManager>(); root.AddComponent<SceneLoader>(); root.AddComponent<Sleeper>().TargetFPS = 60.0f; // Attach exit listener bool exit = false; Listener<ExitMessage> exitlistener = root.AddComponent<Listener<ExitMessage>>() as Listener<ExitMessage>; exitlistener.OnMessageReceived += (msg) => exit = true; // Initialise root.Init(); // Send the initialise message InitialiseMessage initmsg = new InitialiseMessage(); pool.SendMessage(initmsg); // Load the scene if (!root.GetComponent<SceneLoader>().LoadSceneFromFile("scene.json")) { Console.WriteLine("Failed to load scene!"); Console.ReadKey(); return; } // Setup the frame message FrameMessage framemsg = new FrameMessage(); framemsg.FrameNumber = 0; framemsg.DeltaTime = 0.0f; // Setup the timer Stopwatch frametimer = new Stopwatch(); // Loop until done while (!exit) { // Send frame message frametimer.Start(); pool.SendMessage(framemsg); frametimer.Stop(); framemsg.DeltaTime = (float)frametimer.Elapsed.TotalSeconds; frametimer.Reset(); // Increase frame number framemsg.FrameNumber++; // Process windows events Application.DoEvents(); } // Send the shutdown message ShutdownMessage shutdownmsg = new ShutdownMessage(); pool.SendMessage(shutdownmsg); // Delete root actor and clean up root.Destroy(true); }
public void OnShutdown(ShutdownMessage msg) { // Debug Console.WriteLine("Shutting down renderer..."); // Clean up all shader resource views /*foreach (var pair in shaderresourcemap) pair.Value.Dispose(); shaderresourcemap.Clear(); shaderresourcemap = null; // Clean up the sampler states smpClamp.Dispose(); smpClamp = null; // Clean up the meshes mshrQuad.Dispose(); mshrQuad = null; mshQuad = null; // Clean up the shaders shdBasic.Dispose(); shdBasic = null;*/ // Clean up the RT and depth buffer vwDepthBuffer.Dispose(); vwDepthBuffer = null; texDepthBuffer.Dispose(); texDepthBuffer = null; rtBackbuffer.Dispose(); rtBackbuffer = null; // Clean up the depth states Depth_Disabled.Dispose(); Depth_Disabled = null; Depth_Enabled.Dispose(); Depth_Enabled = null; // Shutdown the swapchain and device swapchain.Dispose(); swapchain = null; Device.Dispose(); Device = null; // Cleanup other stuff context = null; // Cleanup the window window.Dispose(); window = null; }
public void Transmit(ShutdownMessage msg) { Console.WriteLine("Transmitting"); byte[] b = msg.GetMessage(); stream.Write(b, 0, b.Length); }
private void HandleShutDownMessage(ShutdownMessage message) { SavePortfolioToDatabase(); UploadLimitOrdersToDatabase(); }
private void OnShutdownRequested(ShutdownMessage message) { var gatherDataMessage = new ApplicationStateRequestedMessage(); MessengerInstance.Send(gatherDataMessage); this.statePersistence.Persist(gatherDataMessage.PersistentData); }