PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, April 20, 2022

[FIXED] What event should I use for closing client websocket in Electron application?

 April 20, 2022     connection, dom-events, electron, javascript, websocket     No comments   

Issue

I have Electron application. There is websocket connection between server and client side of electron app (another words, I use websocket on index.html).

I need to close websocket connection, when user closes the application. What event should I use for it?

There is mainWindow.on('closed', () => { }); but I have no access to browser code at this point.


Solution

You should use IPC (Internal Process Communication). In the electron framework, there are two processes:

  • Main (The main process creates web pages by creating BrowserWindow instances.)
  • Renderer (The main process manages all web pages and their corresponding renderer processes)

These two can communicate together using IPC. For more details see docs



Answered By - Ashot
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing