Like node-zephyros, but simplified, and prefer callbacks then promise.
With Zephros, you are able to get window_ids, screen_ids, app_ids and talk ot listen to them. Mainly it is used to add key bindings for window resizing and moving.
Thie module is a thin wrapper on Zephros's protocol. It has language bindings in several languages, even one called [node-zephyros] wrapped with promise. You may find [more about the bindings in the repo][bindngs].
We got lots of callbacks:
npm install --save node-zephyros-callback
z = require './bind.coffee'require 'proto-task-wait-done'zconnect port: 1235->zall_windows# returnwindowsmapzsend window_id'title'zsend window_id'app'zsend app_id'title'consolelog titleapp_titlezsend null'bind''e''cmd''alt'->consolelog 'cmd alt e'zbind 'l''cmd''alt'->zfocused_windowzmain_screenzsend screen_id'frame_including_dock_and_menu'half_w = Mathround framew / 2half_h = Mathround frameh / 2zsend window_id'set_frame'x: 0y: 0w: half_wh: frameh->zbind 'r''cmd''alt'->zfocused_window# console.log 'window_id', window_idzmain_screenzsend screen_id'frame_including_dock_and_menu'half_w = Mathround framew / 2half_h = Mathround frameh / 2zsend window_id'set_frame'x: half_wy: 0w: half_wh: frameh->
Before using this, you should read its protocol and have some basic ideas about using that.
node-zephyros-callback connects to Zephros with a TCP connection, which means you need to set Zephros to listen to a TCP port in its preference. The default port is
1235, code it like this:
z = require 'node-zephyros-callback'zconnect port: 1235-># `z` is the entry# do stuffs after connection is established
Every message was consists of 4 parts like:
[msg_id, receiver_id, method, *args],
node-zephyros-callback will take case of
msg_id and make it into a callback,
so you don't have to write
receiver_ids are required at times.
z.send is for sending messages and attaching each with a callback, followed with a
window_id -- the
'title' -- the
method, some or zero
*args, and an optional callback, like this demo:
zall_windows# returnwindowsmapzsend window_id'title'zsend window_id'app'zsend app_id'title'consolelog titleapp_title
Top level APIs use
receiver_id, so they are attached to
That why there's code like this:
zall_windows# `windows` is an array of `id`s, or exactly an array of numbers by now
Events are attached to
z too, you may write like this:
my.coffee for what I have now.
This module is not well tested, you may still find some problems.
If you find bugs, please report at issue or folk it, the code is short.