Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way for javascript to call back to the overlay plugin. #24

Merged
merged 1 commit into from
Nov 8, 2017

Conversation

danakj
Copy link

@danakj danakj commented Nov 6, 2017

This adds an overlayMessage() function to the OverlayPluginApi object,
which will call a virtual OverlayMessage() function on OverlayBase.
Plugins can override it and parse the string to do whatever they wish,
such as Text-to-Speech for example.

The sendMessage() function takes 2 arguments, which are the |name| of
the overlay plugin to send it to, and the |message| string to send.
overlayMessage() takes the same 2 arguments.

In order to send the overlayMessage() to the same plugin which is
running the javascript, the name of the plugin needs to be known,
but it is user defined. So we also add an |overlayName| readonly
string to the OverlayPluginApi object, that has the name of the
overlay plugin. Then the javascript may do the following to send
a string to its c# plugin:

OverlayPluginApi.overlayMessage(OverlayPluginApi.overlayName, 'hello');

This adds an overlayMessage() function to the OverlayPluginApi object,
which will call a virtual OverlayMessage() function on OverlayBase.
Plugins can override it and parse the string to do whatever they wish,
such as Text-to-Speech for example.

The sendMessage() function takes 2 arguments, which are the |name| of
the overlay plugin to send it to, and the |message| string to send.
overlayMessage() takes the same 2 arguments.

In order to send the overlayMessage() to the same plugin which is
running the javascript, the name of the plugin needs to be known,
but it is user defined. So we also add an |overlayName| readonly
string to the OverlayPluginApi object, that has the name of the
overlay plugin. Then the javascript may do the following to send
a string to its c# plugin:

OverlayPluginApi.overlayMessage(OverlayPluginApi.overlayName, 'hello');
@danakj
Copy link
Author

danakj commented Nov 6, 2017

Hello! I'm working to add text-to-speech in cactbot (https://github.com/quisquous/cactbot/) but we need a way to get a message from JS to C#. The sendMessage() function almost works but has 2 problems:

  1. The function in OverlayBase is not virtual, so we can't override it, and it's meant for sending the message back to javascript anyhow.
  2. The name of the plugin isn't known in js to sendMessage() to it.

This should solve both of those, with a new function to not make sendMessage do different things for different plugins - whereas overlayMessage() will do something specific to that overlay plugin.

Thanks!

danakj added a commit to quisquous/cactbot that referenced this pull request Nov 6, 2017
This depends on a patch to OverlayPlugin found at
hibiyasleep/OverlayPlugin#24
danakj added a commit to quisquous/cactbot that referenced this pull request Nov 6, 2017
This depends on a patch to OverlayPlugin found at
hibiyasleep/OverlayPlugin#24
danakj added a commit to quisquous/cactbot that referenced this pull request Nov 6, 2017
This depends on a patch to OverlayPlugin found at
hibiyasleep/OverlayPlugin#24
danakj added a commit to quisquous/cactbot that referenced this pull request Nov 6, 2017
This depends on a patch to OverlayPlugin found at
hibiyasleep/OverlayPlugin#24
danakj added a commit to quisquous/cactbot that referenced this pull request Nov 6, 2017
This depends on a patch to OverlayPlugin found at
hibiyasleep/OverlayPlugin#24
@ezsoftware
Copy link

I'm curious, what events are being handled in the client side (javascript inside chromium) that the server side (ACT plugin) isn't aware of that requires the client side to send a request back to the server-side code to process for TTS?

From my quick review of your pull request, I don't see any issues with the implementation, I'm just curious about how the need for it arose.

Also, is there any problem with me including Cactpot as part of the installer bundle with OverlayPlugin, OverlayPlugin-Themes, and Enmity addon?

@danakj
Copy link
Author

danakj commented Nov 6, 2017

The JS processes log events, and has complex logic that we don't want to express in the c# plugin. It decides to show things on screen, play sounds, or in this case read text-to-speech. You can have a look at the cactbot readme (the link above) to see more about the built-in UIs it provides.

Also, is there any problem with me including Cactpot as part of the installer bundle with OverlayPlugin, OverlayPlugin-Themes, and Enmity addon?

There's no problem IMO, it'd be exciting to see it in more hands. We've been gearing up to the point of getting it out to more people and we feel it's in pretty good shape (the TTS will really help for people who expect that from other ACT interactions tho). But pls spell it "Cactbot" :)

@quisquous
Copy link

quisquous commented Nov 6, 2017

I'm curious, what events are being handled in the client side (javascript inside chromium) that the server side (ACT plugin) isn't aware of

Largely, this is for expressing more complicated triggers, e.g. https://github.com/quisquous/cactbot/blob/master/ui/raidboss/data/triggers/susano-ex.js#L60. Other plugins like triggernometry or the built in custom triggers in ACT do this all in C#, but cactbot does it in javascript.

Also, is there any problem with me including Cactpot as part of the installer bundle with OverlayPlugin, OverlayPlugin-Themes, and Enmity addon?

I'd be excited to see cactbot included with the OverlayPlugin bundle too, as long as there's a link to https://github.com/quisquous/cactbot/ somewhere in the installer bundle documentation so users know how to set up cactbot.

The only downside I can think of is that it could make distribution a little bit more awkward for the bundle. It means that the cactbot that comes with the bundle might be outdated (or might not even work properly with the latest ffxiv plugin). I don't want to force the bundle to have to release just because cactbot does. cactbot does have a version check though and will tell users to go update, so maybe that's good enough?

danakj added a commit to quisquous/cactbot that referenced this pull request Nov 8, 2017
This depends on a patch to OverlayPlugin found at
hibiyasleep/OverlayPlugin#24
@hibiyasleep hibiyasleep merged commit cb552b1 into hibiyasleep:master Nov 8, 2017
@hibiyasleep
Copy link
Owner

This will be included in 0.3.4.0, thanks for great work!

@danakj
Copy link
Author

danakj commented Nov 8, 2017

Thanks :D

@ezsoftware
Copy link

@quisquous

Its not a problem, I already do it for enmity plugin (and to a lesser extent themes as well, though themes generally doesn't have any breaking changes between non-expansion updates) and I try to streamline my custom build scripts to automate the process as much as possible.

The enmity plugin has the update notices too, so I think that will work well. People who don't want to wait for me to update the bundle can grab the updates manually, otherwise they can wait for the bundle, so it shouldn't be too big of an issue.

I'll work on getting it integrated this weekend.

danakj added a commit to quisquous/cactbot that referenced this pull request Nov 9, 2017
This depends on a patch to OverlayPlugin found at
hibiyasleep/OverlayPlugin#24
danakj added a commit to quisquous/cactbot that referenced this pull request Nov 13, 2017
This depends on a patch to OverlayPlugin found at
hibiyasleep/OverlayPlugin#24
quisquous pushed a commit to quisquous/cactbot that referenced this pull request Nov 19, 2017
This depends on a patch to OverlayPlugin found at
hibiyasleep/OverlayPlugin#24
quisquous pushed a commit to quisquous/cactbot that referenced this pull request Nov 20, 2017
This depends on a patch to OverlayPlugin found at
hibiyasleep/OverlayPlugin#24
@danakj
Copy link
Author

danakj commented Nov 21, 2017

@hibiyasleep Do you have any plans about when 0.3.4.0 will be happening? We're excited to give people TTS :)

@hibiyasleep
Copy link
Owner

I'm currently on travel. I'll release within 3-4 days, sorry for much delay :(

@danakj
Copy link
Author

danakj commented Nov 21, 2017

Oh no problem, thanks! That's really great news.

quisquous pushed a commit to quisquous/cactbot that referenced this pull request Nov 25, 2017
This depends on a patch to OverlayPlugin found at
hibiyasleep/OverlayPlugin#24
@hibiyasleep
Copy link
Owner

@danakj @ezsoftware now released, sorry I'm too late (._.

@danakj
Copy link
Author

danakj commented Nov 28, 2017

Thanks very much :)

quisquous pushed a commit to quisquous/cactbot that referenced this pull request Nov 28, 2017
This depends on a patch to OverlayPlugin found at
hibiyasleep/OverlayPlugin#24
hibiyasleep pushed a commit that referenced this pull request Dec 15, 2019
Extend try block to cover isValid for enmity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants