项目作者: moteus

项目描述 :
Implementation of Growl Notify Transport Protocol (GNTP) for Lua
高级语言: Lua
项目地址: git://github.com/moteus/lua-gntp.git
创建时间: 2015-03-30T11:10:29Z
项目社区:https://github.com/moteus/lua-gntp

开源协议:MIT License

下载


lua-gntp

Build Status
Coverage Status
License

Implementation of Growl Notify Transport Protocol (GNTP) for Lua

Make common GNTP objects

  1. local icon = GNTP.Resource.load_from_file('coulson.jpg')
  2. local app = GNTP.Application.new{'LLUV_GNTP', icon = icon,
  3. notifications = {
  4. { 'CONNECT',
  5. title = 'ConnectTitle',
  6. display = 'ConnectDisplay',
  7. enabled = true,
  8. icon = icon
  9. };
  10. { 'DISCONNECT',
  11. title = 'DisconnectTitle',
  12. display = 'DisconnectDisplay',
  13. enabled = true,
  14. icon = icon
  15. };
  16. }
  17. }

Using lluv async connector

  1. local growl = GNTP.Connector.lluv(app, {
  2. host = '127.0.0.1';
  3. port = '23053';
  4. pass = '123456';
  5. encrypt = 'AES';
  6. hash = 'SHA256';
  7. })
  8. growl:register(function(self, err, msg)
  9. print(err or msg:encode())
  10. growl:notify('CONNECT', 'User connected',
  11. function(self, err, msg)
  12. print(err or msg:encode())
  13. end
  14. )
  15. end)

Using LuaSocket sync connector

  1. local growl = GNTP.Connector.luasocket(app, {
  2. host = '127.0.0.1';
  3. port = '23053';
  4. pass = '123456';
  5. encrypt = 'AES';
  6. hash = 'SHA256';
  7. })
  8. local msg, err = growl:register()
  9. print(err or msg:encode())
  10. local msg1, msg2 = growl:notify('CONNECT', {'User connected', callback = true})
  11. if not msg1 then print(msg2)
  12. else
  13. print(msg1:encode())
  14. print(msg2 and msg2:encode())
  15. end