Skip to content

Commit a0ef2cc

Browse files
committed
Merge pull request #9 from SaiFi0102/master
Change to allow using any type other than nil as handler key
2 parents bc56f00 + 2b734d9 commit a0ef2cc

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

AIO_Client/AIO.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ end
784784
-- All parameters the client sends will be passed to func when called
785785
-- Only one function can be a handler for one name (subject for change)
786786
function AIO.RegisterEvent(name, func)
787-
assert(type(name) == "string", "name of the registered event string expected")
787+
assert(name ~= nil, "name of the registered event expected not nil")
788788
assert(type(func) == "function", "callback function must be a function")
789789
assert(not AIO_BLOCKHANDLES[name], "an event is already registered for the name: "..name)
790790
AIO_BLOCKHANDLES[name] = func
@@ -796,7 +796,7 @@ end
796796
-- is received, the handlertable["HandlerName"] will be executed with player and additional params passed to the block.
797797
-- Returns the passed table
798798
function AIO.AddHandlers(name, handlertable)
799-
assert(type(name) == 'string', "#1 string expected")
799+
assert(name ~= nil, "#1 expected not nil")
800800
assert(type(handlertable) == 'table', "#2 a table expected")
801801

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

@@ -947,7 +947,7 @@ else
947947

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

AIO_Server/AIO.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ end
784784
-- All parameters the client sends will be passed to func when called
785785
-- Only one function can be a handler for one name (subject for change)
786786
function AIO.RegisterEvent(name, func)
787-
assert(type(name) == "string", "name of the registered event string expected")
787+
assert(name ~= nil, "name of the registered event expected not nil")
788788
assert(type(func) == "function", "callback function must be a function")
789789
assert(not AIO_BLOCKHANDLES[name], "an event is already registered for the name: "..name)
790790
AIO_BLOCKHANDLES[name] = func
@@ -796,7 +796,7 @@ end
796796
-- is received, the handlertable["HandlerName"] will be executed with player and additional params passed to the block.
797797
-- Returns the passed table
798798
function AIO.AddHandlers(name, handlertable)
799-
assert(type(name) == 'string', "#1 string expected")
799+
assert(name ~= nil, "#1 expected not nil")
800800
assert(type(handlertable) == 'table', "#2 a table expected")
801801

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

@@ -947,7 +947,7 @@ else
947947

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

0 commit comments

Comments
 (0)