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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

djcas9 opened this issue · comments

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

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

  • add appCmdSetAsDefaultProtocolClient and appEventSetAsDefaultProtocolClient` here
  • add a case statement here listening for appCmdSetAsDefaultProtocolClient, execute app.setAsDefaultProtocolClient with the args provided in the json object, and return the boolean result of the function in a appEventSetAsDefaultProtocolClient event using a success json key

In the go project:

  • add the following attributes here:
    • Protocol string
    • Args []string
    • Success *bool
  • add appCmdSetAsDefaultProtocolClient and appEventSetAsDefaultProtocolClient here
  • add a (a *Astilectron) SetAsDefaultProtocolClient(protocol, path string, args []string) error method that will do this:
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
}

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

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).