dnwk / xmpphp

Automatically exported from code.google.com/p/xmpphp
0 stars 0 forks source link

Basic MUC (groupchat) support #131

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
XMPPHP can't join groups chats.

Patch:

$ diff -r -u xmpphp-0.1rc2-r77/ xmpphp-0.1rc2-r77-my
diff -r -u xmpphp-0.1rc2-r77/XMPPHP/XMPP.php 
xmpphp-0.1rc2-r77-my/XMPPHP/XMPP.php
--- xmpphp-0.1rc2-r77/XMPPHP/XMPP.php   2009-07-26 21:01:08.000000000 +0400
+++ xmpphp-0.1rc2-r77-my/XMPPHP/XMPP.php    2013-03-20 18:17:25.000000000 +0400
@@ -200,14 +200,30 @@
            $out .= "/>";
        } else {
            $out .= ">";
-           if($show != 'available') $out .= "<show>$show</show>";
+           if($show != 'available' and !empty($show)) $out .= "<show>$show</show>";
            if($status) $out .= "<status>$status</status>";
            if($priority) $out .= "<priority>$priority</priority>";
            $out .= "</presence>";
        }

        $this->send($out);
-   }
+    }
+
+    /**
+     * Join multi-user chat room
+     */
+    public function join_groupchat($roomjid) {
+        $id = $this->getId();
+        $out = "<presence from=\"{$this->fulljid}\" id=\"$id\" to=\"$roomjid\" 
/>";
+       $this->send($out);
+    }
+
+    public function exit_groupchat($roomjid) {
+        $id = $this->getId();
+        $out = "<presence from=\"{$this->fulljid}\" id=\"$id\" to=\"$roomjid\" 
type='unavailable' />";
+       $this->send($out);
+    }
+ 
    /**
     * Send Auth request
     *

Original issue reported on code.google.com by TheV...@gmail.com on 4 Apr 2013 at 2:43