|
@@ -16,7 +16,14 @@ if not muc_domain_base then
|
16
|
16
|
end
|
17
|
17
|
|
18
|
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
|
28
|
-- url_from_room_jid will determine the url for a conference
|
22
|
29
|
-- provided a room jid. It is required that muc domain mapping
|
|
@@ -44,9 +51,14 @@ end
|
44
|
51
|
-- event should be triggered. Call events are triggered by status strings
|
45
|
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
|
62
|
module:hook("muc-broadcast-presence", function (event)
|
49
|
63
|
-- Detect if the presence is for a poltergeist or not.
|
50
|
64
|
if not
|
|
@@ -57,8 +69,28 @@ module:hook("muc-broadcast-presence", function (event)
|
57
|
69
|
return
|
58
|
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
|
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
|
96
|
end, -101);
|