asticode / astilectron

Electron app that provides an API over a TCP socket that allows executing Electron's method as well as capturing Electron's events
MIT License
285 stars 67 forks source link

app.setAsDefaultProtocolClient(protocol[, path, args]) #57

Open djcas9 opened 2 years ago

djcas9 commented 2 years ago

Doc: https://www.electronjs.org/docs/latest/api/app#appsetasdefaultprotocolclientprotocol-path-args

How could I go about adding support for something like this?

asticode commented 2 years ago

You'll need to modify both go and JS projects.

Regarding the JS project, here's what you need to do:

In the go project:

var e Event
if e, err = synchronousEvent(a.worker.Context(), a, a.writer, Event{Name: appCmdSetAsDefaultProtocolClient, Protocol: protocol, Path: path, Args: args}, appEventSetAsDefaultProtocolClient); err != nil {
  // TODO Process error the same way this package handle errors
  return
}

if !e.Success {
  //return an error as well
}
zerotao commented 2 years ago

Let me know if there is anything strange you would like changed, modified, etc.

zerotao commented 2 years ago

One aspect I am not sure fits the model you have built (and maybe there is a more general approach). Specifically capturing open-url in the way I did.

It feels like there should be a way to achieve the same thing from go-astilectron w/o needing to modify astilectron but I didn't see anything (or didn't look hard enough).