-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.lua
More file actions
executable file
·70 lines (54 loc) · 1.72 KB
/
Copy pathclient.lua
File metadata and controls
executable file
·70 lines (54 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env luajit
--[[----------------------------------------------------------------------------
client.lua
@author Christophe Berbizier (cberbizier@peersuasive.com)
@license GPLv3
@copyright
(c) 2013, Peersuasive Technologies
------------------------------------------------------------------------------]]
--[[ REQUIREMENTS ]]------------------------------------------------------------
local zmq = require "zmq"
require "zmq.poller"
local c = zmq.init(1)
local s = c:socket(zmq.PAIR)
assert( s:connect("tcp://127.0.0.1:20051") )
local r = function(...)
local args = {...}
-- a possible alternative way of creating a component (unimplemented)
--[[
local button = {
class = "TextButton",
name = "theNewTextButton",
setName = "theNewTextButton",
setButtonText = "The New Text Button",
setBounds = { 20, 40, 200, 200 }
}
createComponent( button )
--]]
local b = all["button2"]
if not b then
local button2 = luce:TextButton():new()
button2:setButtonText( "Button 2!")
button2:setName("button2")
button2:setBounds{ 10, 200, 150, 150 }
all["button2"] = button2
button2:buttonClicked(function(...)
print("remote button clicked !!")
end)
mc:addAndMakeVisible( button2 )
else
b:setButtonText( args.newText or "updated !")
b:buttonClicked(function(...)
print("new remote button callback")
end)
end
-- local b = mc:getChildComponent( "button2" )
-- if ( b ) then
-- b:setName("updated!")
-- else
-- b = luce:TextButton():new("newButton")
-- ...
end
s:send( string.dump( r ) )
s:close()
c:term()