From 60e271a3cc3ffefe10fc34282cef88f7dff0eabe Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Thu, 3 Jul 2014 15:49:07 +0200 Subject: [PATCH] MT#7679 xavp:get() function --- ngcp/xavp.lua | 9 +++++++++ tests/ngcp_xavp.lua | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/ngcp/xavp.lua b/ngcp/xavp.lua index a2e4edd..e60dec9 100644 --- a/ngcp/xavp.lua +++ b/ngcp/xavp.lua @@ -141,6 +141,15 @@ NGCPXAvp_MT = { end end + function NGCPXAvp:all(key) + if key then + local t = sr.xavp.get(self.name, 0, 0) + if t then + return t[key]; + end + end + end + function NGCPXAvp:clean(key) if key then local id = string.format("$xavp(%s[0]=>%s)", self.name, key) diff --git a/tests/ngcp_xavp.lua b/tests/ngcp_xavp.lua index e762090..520bbd2 100644 --- a/tests/ngcp_xavp.lua +++ b/tests/ngcp_xavp.lua @@ -83,6 +83,14 @@ TestNGCPXAvp = {} --class assertItemsEquals(xavp("testid"), "1") end + function TestNGCPXAvp:test_xavp_get_all() + xavp = NGCPXAvp:new("caller", "peer", vals) + sr.pv.sets("$xavp(caller_peer=>testid)", "value") + assertEquals(xavp("testid"), "value") + sr.pv.sets("$xavp(caller_peer=>testid)", "1") + assertItemsEquals(xavp:all("testid"), {"1", "value"}) + end + function TestNGCPXAvp:test_xavp_set() local xavp = NGCPXAvp:new("caller", "peer", vals) local vals = {1,"2",3,nil}