瀏覽代碼

Merge pull request #2966 from jmacelroy/call-response

Adding cancel to mod_muc_call
j8
Aaron van Meerten 7 年之前
父節點
當前提交
1ba564f49c
No account linked to committer's email address
共有 2 個文件被更改,包括 51 次插入5 次删除
  1. 13
    1
      resources/prosody-plugins/ext_events.lib.lua
  2. 38
    4
      resources/prosody-plugins/mod_muc_call.lua

+ 13
- 1
resources/prosody-plugins/ext_events.lib.lua 查看文件

9
    module:log("warn", "Implement this lib to trigger external events.")
9
    module:log("warn", "Implement this lib to trigger external events.")
10
 end
10
 end
11
 
11
 
12
+-- cancel will perform the trigger for external call cancellation.
13
+-- This trigger is left unimplemented. The implementation is expected
14
+-- to be specific to the deployment.
15
+local function cancel(stanza, url, reason)
16
+   module:log(
17
+	  "warn",
18
+	  "A module has been configured that triggers external events."
19
+   )
20
+   module:log("warn", "Implement this lib to trigger external events.")
21
+end
22
+
12
 
23
 
13
 local ext_events = {
24
 local ext_events = {
14
-   invite = invite
25
+   invite = invite,
26
+   cancel = cancel
15
 }
27
 }
16
 
28
 
17
 return ext_events
29
 return ext_events

+ 38
- 4
resources/prosody-plugins/mod_muc_call.lua 查看文件

16
 end
16
 end
17
 
17
 
18
 -- Status strings that trigger call events.
18
 -- Status strings that trigger call events.
19
-local invited_status = "Invited"
19
+local invited_status  = "Invited"
20
+local calling_status  = "Calling"
21
+local ringing_status  = "Ringing"
22
+local busy_status     = "Busy"
23
+local rejected_status = "Rejected"
24
+local connected_status = "connected"
25
+
26
+
20
 
27
 
21
 -- url_from_room_jid will determine the url for a conference
28
 -- url_from_room_jid will determine the url for a conference
22
 -- provided a room jid. It is required that muc domain mapping
29
 -- provided a room jid. It is required that muc domain mapping
44
 -- event should be triggered. Call events are triggered by status strings
51
 -- event should be triggered. Call events are triggered by status strings
45
 -- the status strings supported are:
52
 -- the status strings supported are:
46
 --    -------------------------
53
 --    -------------------------
54
+--    Status      | Event Type
47
 --    _________________________
55
 --    _________________________
56
+--    "Calling"   | INVITE
57
+--    "Invited"   | INVITE
58
+--    "Ringing"   | CANCEL
59
+--    "Busy"      | CANCEL
60
+--    "Rejected"  | CANCEL
61
+--    "connected" | CANCEL
48
 module:hook("muc-broadcast-presence", function (event)
62
 module:hook("muc-broadcast-presence", function (event)
49
     -- Detect if the presence is for a poltergeist or not.
63
     -- Detect if the presence is for a poltergeist or not.
50
     if not
64
     if not
57
 	   return
69
 	   return
58
     end
70
     end
59
 
71
 
60
-    if event.stanza:get_child_text("status") == invited_status then
72
+	local invite = function()
73
+		 local url = assert(url_from_room_jid(event.stanza.attr.from))
74
+		 ext_events.invite(event.stanza, url)
75
+	end
76
+
77
+	local cancel = function()
61
 	   local url = assert(url_from_room_jid(event.stanza.attr.from))
78
 	   local url = assert(url_from_room_jid(event.stanza.attr.from))
62
-	   ext_events.invite(event.stanza, url)
63
-    end
79
+	   local status = event.stanza:get_child_text("status")
80
+	   ext_events.cancel(event.stanza, url, string.lower(status))
81
+	end
82
+
83
+	local switch = function(status)
84
+	   case = {
85
+		  [invited_status]   = function() invite() end,
86
+		  [calling_status]   = function() invite() end,
87
+		  [ringing_status]   = function() cancel() end,
88
+		  [busy_status]      = function() cancel() end,
89
+		  [rejected_status]  = function() cancel() end,
90
+		  [connected_status] = function() cancel() end
91
+	   }
92
+	   if case[status] then case[status]() end
93
+	end
94
+
95
+	switch(event.stanza:get_child_text("status"))
64
 end, -101);
96
 end, -101);

Loading…
取消
儲存