Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] APIHeartBeat -- A visual cue that the API is running.

February 02 (10 years ago)

Edited February 03 (10 years ago)
The Aaron
Pro
API Scripter
Updated v.3 -- Added help with --help. Default to a lower bandwidth update rate. Only adjust players that are online. Restores original user color. Interpolation between two colors.


APIHeartBeat shows you that the API is running by oscillating the color of the toggling user between black and red. If it gets stuck on a color, the API has probably crashed.


You can toggle yourself to be an API HeartBeat Monitor by executing:
!api-heartbeat
HeartBeat state is remember across restarts, so once it's on, you will always have the HeartBeat running until you turn it off again.

GIT: https://github.com/shdwjk/Roll20API/blob/master/AP...
February 02 (10 years ago)

Edited February 02 (10 years ago)
vÍnce
Pro
Sheet Author
Necessity is the mother of invention. -Plato
February 02 (10 years ago)
Lithl
Pro
Sheet Author
API Scripter

How does it interact with the default color for drawings and the color for pings? I mean, obviously the new colors will get picked up, but has it affected their utility?

Have you used this in an actual game? Is it distracting?

Glancing at the code, you appear to be limiting the color cycle to black-red on a sine (ish) wave; what if the user wants to keep their color?

February 02 (10 years ago)
The Aaron
Pro
API Scripter
All Good questions Brian!

It actually interacts very interestingly with pings, as the player color changing gets reflected in the concentric rings. Seems to still have the same utility.

Haven't tried it in a game (bring on the feedback!), my next game isn't until thursday. Distracting? Maybe? It probably depends on the person.

I was going for a "heart beat" look with the sine derived wave form. Unfortunately, it doesn't really come through. I'll probably just change it to a simple sine wave, or perhaps just changing it every few seconds. (feedback welcome!)
February 02 (10 years ago)
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter

The Aaron said:

APIHeartBeat shows you that the API is running by oscillating the color of the toggling user between black and red. If it gets stuck on a color, the API has probably crashed.


You can toggle yourself to be an API HeartBeat Monitor by executing:
!api-heartbeat
HeartBeat state is remember across restarts, so once it's on, you will always have the HeartBeat running until you turn it off again.

GIT: https://github.com/shdwjk/Roll20API/blob/master/AP...

This idea is so good and clever its annoying.
February 02 (10 years ago)
The Aaron
Pro
API Scripter
It sprung out of chatting with Russ Hapke when I was demoing the API for him (on the worst possible night, incidentally..). I told him that some people use the spinning TurnMarker graphic to tell if the API had crashed. I was trying to think of some way of making that concept as a script. this was the only thing I could come up with that is always visible.

Still remains to be seen if it actually is useful in game. =D
Does it have to be set to a certain color or does any work? I can't seem to get it working.
I like the idea, I can't count how many times I crashed it making macros and couldn't tell for a few minutes if the API crashed.
February 02 (10 years ago)
The Aaron
Pro
API Scripter
You should just need to install the script and run !api-heartbeat

Currently, it's not configurable what color to set it to, but that could be done without much trouble.
February 02 (10 years ago)
vÍnce
Pro
Sheet Author
Can't get it to run here... using !api-heartbeat
February 02 (10 years ago)
The Aaron
Pro
API Scripter
Ok. Just pushed a new version with a simplified sine wave. See if that works. I probably should add some feedback from the script...
February 02 (10 years ago)

Edited February 02 (10 years ago)
vÍnce
Pro
Sheet Author
working now. It will cycle your dice color as well. Although white doesn't seem to be one of the colors used by the script, sometimes my powercards end up with a white background(header) with white text...?
Works good now bud, I like it!
February 02 (10 years ago)
The Aaron
Pro
API Scripter
Interesting.. hadn't considered the dice aspect. (I don't use 3d dice). Does it cycle them while they are rolling or just take the current color on roll?
February 02 (10 years ago)
The Aaron
Pro
API Scripter
Cool! Can't wait to hear how it goes in game. =D
February 02 (10 years ago)

Edited February 02 (10 years ago)
vÍnce
Pro
Sheet Author

The Aaron said:

Interesting.. hadn't considered the dice aspect. (I don't use 3d dice). Does it cycle them while they are rolling or just take the current color on roll?
It grabs the cycled color. I think I saw black on black dice on one roll, but I could be wrong. Haven't been able to repeat it. Update: confirmed. Black on Black for some rolls. Can't read the result on dice.
February 02 (10 years ago)

Edited February 02 (10 years ago)
vÍnce
Pro
Sheet Author
Might be nice to just cycle thru a few shades of a color. That way the GM keeps his hue and I think it would be less distracting.
February 02 (10 years ago)
The Aaron
Pro
API Scripter
Good idea. I'll certainly make that an option. =D
February 02 (10 years ago)

Edited February 02 (10 years ago)

Stephen S. said:

This idea is so good and clever its annoying.

QFT. But I'd recommend it to have a longer delay as i'm not sure how much throughput the API server can handle along with other scripts running. During peak hours it would get pretty bad. I write my scripts to perform as few updates as possible to reduce the amount of calls.
February 02 (10 years ago)

Edited February 02 (10 years ago)
The Aaron
Pro
API Scripter
QFT? Ah, looked it up. Thanks!

Yeah, might need to add an adjustment. Currently it updates 5 times per second. I've had other scripts that update 10 times per second without issue. In particular, this isn't a very expensive operation for the API to perform. There is some question as to the effect on the client side, so be sure to let me know if you run into anything like that.
February 02 (10 years ago)
Roger A.
Sheet Author
Well, Riley did just say they doubled the processing power on the API server during today's maintenance, so we should have some head room for a while, but we should try to keep our scripts(or the scripts that other people make and I steal at least, since I don't know enough to write from scratch) as low resource as possible.
February 02 (10 years ago)

Edited February 02 (10 years ago)

The Aaron said:

QFT? Ah, looked it up. Thanks!

this isn't a very expensive operation for the API to perform.
I'm not aware of the complete topology, but I assumed that the API server sent updates to each client connected to a campaign. For something that updates n times a second for m connected clients is n*m updates sent per second by the server. That alone isnt enough, but throw in a bunch of other things on that one sandbox, then the number of campaigns running and.. well the result is it may get bogged down trying to serve all those requests.

Really depends on the network model used, queuing system used (simultaneous detection for packet compression etc..). I'm not a network engineer, but given the profession we all dabble in many things.

February 02 (10 years ago)
Yes, very yes, amazing. Up until now i was using a statusmarker toggle as a test haha!
February 02 (10 years ago)
The Aaron
Pro
API Scripter

Ken L. said:

I'm not aware of the complete topology, but I assumed that the API server sent updates to each client connected to a campaign. For something that updates n times a second for m connected clients is n*m updates sent per second by the server. That alone isnt enough, but throw in a bunch of other things on that one sandbox, then the number of campaigns running and.. well the result is it may get bogged down trying to serve all those requests.

Really depends on the network model used, queuing system used (simultaneous detection for packet compression etc..). I'm not a network engineer, but given the profession we all dabble in many things.

Sure. I'm just saying this is no different than say, setting the hit points on a token. Could change it to be reaction based instead of on an interval. Maybe have it change to a random bright color different than current whenever a token changed... options. =D
February 02 (10 years ago)
Great job, Aaron! You might be able to solve the problem of it being too distracting (if it indeed turn out to be a problem) by making the color shift more subtle. No reason to go all the way to black. Just have it "throb" enough to be discernible when you look directly at it, but not distracting when it's part of your periphery. Also, why not just use the color the GM has assigned to himself?
February 02 (10 years ago)
oh hey, lol. I'm the some people that use it that way :P or at the first one to point it out as a way of quickly telling if it runs. I like this though, its even neater :P
February 02 (10 years ago)
The Aaron
Pro
API Scripter
Ah, it figures it'd be you Michael! hahahahaha. =D

Yeah, making a more subtle shift is probably a good idea. Could even take arguments to the command to set the two color bounds and possibly an operation to use to shift between them. (simple alternate, oscillate, flicker every 5 seconds, etc..)

Guess I'll add those to my list...
February 02 (10 years ago)
Gen Kitty
Forum Champion
Creeping featurism strikes again!
February 02 (10 years ago)
The Aaron
Pro
API Scripter
Next thing you know, it will be almost as complicated as TokenMod... =D
February 02 (10 years ago)

Edited February 02 (10 years ago)
Riley D.
Roll20 Team
First off, I assume this is mostly a reaction to the recent downtime we've had with the API server. Those issues should (hopefully) be behind us, and honestly I'd rather we get to a point where you just "know" that the API server will be up rather than needing a check like this. Obviously that hasn't been the case recently, though :-)

With that said, it's not a bad idea, so if you want to do it, go for it. However:

The Aaron said:

Ken L. said:

I'm not aware of the complete topology, but I assumed that the API server sent updates to each client connected to a campaign. For something that updates n times a second for m connected clients is n*m updates sent per second by the server. That alone isnt enough, but throw in a bunch of other things on that one sandbox, then the number of campaigns running and.. well the result is it may get bogged down trying to serve all those requests.

Really depends on the network model used, queuing system used (simultaneous detection for packet compression etc..). I'm not a network engineer, but given the profession we all dabble in many things.

Sure. I'm just saying this is no different than say, setting the hit points on a token. Could change it to be reaction based instead of on an interval. Maybe have it change to a random bright color different than current whenever a token changed... options. =D

I think it's probably overkill to have something update every 200ms to tell you the API is still up. If the API goes down, you don't need to know *that* quickly. Honestly, I think just having a "!apiup" command that responds with a whisper is probably sufficient. If you do want something that is going to constantly tell you the API is running, I would back it off quite a bit. 1 second tops, 5 seconds is probably more what I would choose, but again I'm not going to say you can't do it or anything.

I'm also not a fan of the idea that a single campaign would be sending that info to several player objects redundantly, though...why not just make it so it sends to the player who most recently requested it? In addition, it wouldn't be a bad idea to only send the request to online players so you're not changing the color values of players that aren't even being displayed.

The API server would need to send 1 "request" to our real-time shard for each color change (since each thing is happening to a separate object), and then the shard will process (make sure it's valid, store the new value in the database, etc.) that request and send it along to each client. This is a pretty small amount of data so it's not going to be hugely taxing. Then again, if everyone puts it in every campaign it could add up? So who knows.

I think the thing that I would be worried about is over-saturating my own sandbox. We've gotten really good at isolating sandboxes so that they can't use up the resources of the whole API server...you have a limited amount of CPU, memory, and network to work with. Do you want something important like an update to a token for gameplay or a roll from an API command getting slowed down because every 200ms the sandbox is sending 5 requests to change player colors? That would be my biggest concern if I were a GM about using scripts like these that update data constantly.
February 02 (10 years ago)
The Aaron
Pro
API Scripter
That's fair. =D I'll make some changes to the script to respect that. The 200ms update was really more to get a smooth effect. =D Definitely COULD be over used, though I wouldn't expect more than the GM to be using it.
February 02 (10 years ago)
vÍnce
Pro
Sheet Author
Realistically, I was only planning on enabling the script when testing out new scripts or trying out something that's throwing errors.
February 02 (10 years ago)
The Aaron
Pro
API Scripter
(That's what I'm using it for!)

Maybe I should have two modes:
  • Developing -- Highly active, updates often.
  • Playing -- Low activity, updates rarely.
February 02 (10 years ago)
Riley D.
Roll20 Team

The Aaron said:

(That's what I'm using it for!)

Maybe I should have two modes:
  • Developing -- Highly active, updates often.
  • Playing -- Low activity, updates rarely.

Makes sense to me.
February 02 (10 years ago)
vÍnce
Pro
Sheet Author
and maybe one of those new API buttons to start/save when the API is down...? ;-P

February 02 (10 years ago)
vÍnce
Pro
Sheet Author
As Riley has mentioned, hopefully this shouldn't be an issue for anything other than working bugs out of new scripts and/or new versions of scripts.
February 02 (10 years ago)
The Aaron
Pro
API Scripter
Well, those API buttons couldn't do that for you... =D

Yeah, it was less a response to the API crashing, and more making a specific use script for something (Michael does, as it turns out!) that was a side effect use of another script.
February 02 (10 years ago)
From what I understand of the infrastructure, the weakest link here is Firebase and if Firebase starts to hiccup the shards start collapsing?
February 03 (10 years ago)
Riley D.
Roll20 Team

Ken L. said:

From what I understand of the infrastructure, the weakest link here is Firebase and if Firebase starts to hiccup the shards start collapsing?

The API traffic to Firebase is pretty minimal compared to the traffic of 8,000 people online at peak times. I think we have most of the Firebase issues worked out at least for now, though (we just brought the total number of shards from 10 to 30).
February 03 (10 years ago)

Edited February 03 (10 years ago)
DXWarlock
Sheet Author
API Scripter
Not as fancy looking as Aarons way, and surely not as elegant but would work to see when it stopped and stop anyone for using the script while playing.

If its just for testing, and to make sure people don't leave it running all the time if they do use it. make it use the turn order window, and count down from 10 and repeat, setting the PR on a custom item once a second? One item in the turn order can be minimized rather small, it takes up negligible screen space while testing scripts:

When you do the !on command it adds it and counts down in a loop, when you do its !off command it removes it and stops.
No way anyone would be able to leave that running while trying to play a live game, it would keep overriding their combat turn orders.
February 03 (10 years ago)
The Aaron
Pro
API Scripter
Updated v.3 -- Added help with --help. Default to a lower bandwidth update rate. Only adjust players that are online. Restores original user color. Interpolation between two colors.
February 04 (10 years ago)
vÍnce
Pro
Sheet Author
Thanks Aaron. BTW, the version on github still says v0.2...?
February 04 (10 years ago)
The Aaron
Pro
API Scripter
Thanks Vince! Still getting this new git workflow worked out! It's fixed now!
February 06 (10 years ago)
The Aaron
Pro
API Scripter
Hey All!

Version 0.3 should be hitting the official repo any second now.

Public Service Announcement!

At least one user (Apologies Jeremiah!!) has had a serious performance issue with stuttering and hitching of the screen while panning and scrolling. I'm 95% certain that he was using v0.1. Version v.3 by default should be reasonably minimal in it's impact. However, if you experience any issues, be sure to post here and let me and others know.
Hey man, no biggie! I'll probably crash my stuff many times and have no idea what or how I did it! (I already have) At least with this one it was an easy fix thanks to Steve. It's all a learning process for me but it's still fun!
February 06 (10 years ago)
The Aaron
Pro
API Scripter
Good deal! =D Feel free to reach out to me if you hit anymore issues!
The script seems to have stopped working for me altogether. Is anyone else experiencing this?

Thanks!
March 25 (10 years ago)
The Aaron
Pro
API Scripter
I'll have to give it a try tomorrow.
March 25 (10 years ago)
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
No one is going to ask the obvious question?

Ok then...

Malcolm, did you check if your APIheartbeat stop because the API crashed?

I know that isn't it, but someone had to ask, so there, the obvious question has been asked.
March 25 (10 years ago)
The Aaron
Pro
API Scripter
Ha! That really IS the obvious question! =D
March 25 (10 years ago)
The Aaron
Pro
API Scripter
Ok, I tried it and it worked fine for me. Something else going on?
No, the thing has not been working for me lately. I've gone in an restarted in the Scripts panel and everything — stlll won't "throb"...