ID:2025352
 
Interface commands such as winset & winget take a long time to return, by which I mean approximately a couple tenths of a second each. Is there any way to speed the process?
Is there any way to speed the process?

Not directly, no.

However, client-side interface-foo is possible using javascript:

http://www.byond.com/forum/?post=1477869

Since Javascript executes on the client-side, the information doesn't have to travel from the server to the client back to the server, making client-side winsets/wingets significantly more responsive.

Obviously, invoking javascript functions takes the same time to get to the client as a winset call would, but the benefit of offloading interface handling to the client instead of managing it all on the server is that you lose the latency of multiple calls having to wait for the roundtrip.

Normally, a winget/winset chain looks something like this:

winget() //wait for client to receive invocation, get information, send it back, and for the server to receive and process it.
winset() //wait for the client to receive invocation and apply the information and the server to receive the client's notice that it received the invocation.

Whereas a javascript function handling it, you can simply:

browse() //invoke the javascript function. The server doesn't care about what happens next.


You can use "winset?id=&command=" formatting to invoke verbs from javascript as well to make communicating with the client's UI much easier.

Javascript can also allow you to perform some limited responsiveness into DS, for instance, you can detect when a window has been resized (not just when it's finished resizing, but while actively being resized) using javascript event listeners and then fire a verb to the server, or manually handle all sorts of responsive winsets on the client.

You can also use some interesting hacks to detect the mouse position.

Or you can poll window/element positions periodically via javascript without having to worry about gumming up the works on the server.


If you aren't good with JS, you can at least mitigate some of the slowdown by making sure you are efficiently using winsets/wingets. You will need to make sure that you batch your winset commands to speed them up and prevent slowdowns.

winset(client,"id","pos=[x],[y]")
winset(client,"id2","pos=[x2][y2]")

Should be batched as:

winset(client,null,"id.pos=[x],[y];id2.pos=[x2],[y2]")

Where possible, you should always batch winsets and wingets rather than waiting on them back to back.
Wow, that's really helpful actually. I'm definitely affiliated with JS, I've just never toyed with it in DM. Thanks Ter