Skip to content

Commit

Permalink
Merge pull request #9 from SaiFi0102/master
Browse files Browse the repository at this point in the history
Change to allow using any type other than nil as handler key
  • Loading branch information
Rochet2 committed Aug 23, 2015
2 parents bc56f00 + 2b734d9 commit a0ef2cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions AIO_Client/AIO.lua
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ end
-- All parameters the client sends will be passed to func when called
-- Only one function can be a handler for one name (subject for change)
function AIO.RegisterEvent(name, func)
assert(type(name) == "string", "name of the registered event string expected")
assert(name ~= nil, "name of the registered event expected not nil")
assert(type(func) == "function", "callback function must be a function")
assert(not AIO_BLOCKHANDLES[name], "an event is already registered for the name: "..name)
AIO_BLOCKHANDLES[name] = func
Expand All @@ -796,7 +796,7 @@ end
-- is received, the handlertable["HandlerName"] will be executed with player and additional params passed to the block.
-- Returns the passed table
function AIO.AddHandlers(name, handlertable)
assert(type(name) == 'string', "#1 string expected")
assert(name ~= nil, "#1 expected not nil")
assert(type(handlertable) == 'table', "#2 a table expected")

for k,v in pairs(handlertable) do
Expand Down Expand Up @@ -833,7 +833,7 @@ if AIO_SERVER then
-- A shorthand for sending a message for a handler.
function AIO.Handle(player, name, handlername, ...)
assert(type(player) == 'userdata', "#1 player expected")
assert(type(name) == 'string', "#2 string expected")
assert(name ~= nil, "#2 expected not nil")
return AIO.Msg():Add(name, handlername, ...):Send(player)
end

Expand Down Expand Up @@ -947,7 +947,7 @@ else

-- A shorthand for sending a message for a handler.
function AIO.Handle(name, handlername, ...)
assert(type(name) == 'string', "#1 string expected")
assert(name ~= nil, "#1 expected not nil")
return AIO.Msg():Add(name, handlername, ...):Send()
end

Expand Down
8 changes: 4 additions & 4 deletions AIO_Server/AIO.lua
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ end
-- All parameters the client sends will be passed to func when called
-- Only one function can be a handler for one name (subject for change)
function AIO.RegisterEvent(name, func)
assert(type(name) == "string", "name of the registered event string expected")
assert(name ~= nil, "name of the registered event expected not nil")
assert(type(func) == "function", "callback function must be a function")
assert(not AIO_BLOCKHANDLES[name], "an event is already registered for the name: "..name)
AIO_BLOCKHANDLES[name] = func
Expand All @@ -796,7 +796,7 @@ end
-- is received, the handlertable["HandlerName"] will be executed with player and additional params passed to the block.
-- Returns the passed table
function AIO.AddHandlers(name, handlertable)
assert(type(name) == 'string', "#1 string expected")
assert(name ~= nil, "#1 expected not nil")
assert(type(handlertable) == 'table', "#2 a table expected")

for k,v in pairs(handlertable) do
Expand Down Expand Up @@ -833,7 +833,7 @@ if AIO_SERVER then
-- A shorthand for sending a message for a handler.
function AIO.Handle(player, name, handlername, ...)
assert(type(player) == 'userdata', "#1 player expected")
assert(type(name) == 'string', "#2 string expected")
assert(name ~= nil, "#2 expected not nil")
return AIO.Msg():Add(name, handlername, ...):Send(player)
end

Expand Down Expand Up @@ -947,7 +947,7 @@ else

-- A shorthand for sending a message for a handler.
function AIO.Handle(name, handlername, ...)
assert(type(name) == 'string', "#1 string expected")
assert(name ~= nil, "#1 expected not nil")
return AIO.Msg():Add(name, handlername, ...):Send()
end

Expand Down

0 comments on commit a0ef2cc

Please sign in to comment.