/*
* call-seq:
* leave(string) -> nil
* leave(array) -> nil
*
* Leave the specified group or Array of groups. This only makes sense
* to do if you have previously joined the specified groups via
* #join. However, as of Spread 3.17.3, Spread will _not_ raise an
* error if you attempt to leave a group you aren't a member of.
*/
static VALUE
spconn_leave(VALUE obj, VALUE group)
{
struct SpreadConnection *sp;
int n;
Data_Get_Struct(obj, struct SpreadConnection, sp);
if (TYPE(group) == T_ARRAY)
{
int i;
for (i = 0; i < RARRAY(group)->len; i++)
{
VALUE tmp = RARRAY(group)->ptr[i];
if ((n = SP_leave(sp->mbox, StringValuePtr(tmp))) < 0)
raise_sp_error(n);
}
}
else
{
/* Must be a string or equivalent, raise type error if not */
if ((n = SP_leave(sp->mbox, StringValuePtr(group))) < 0)
raise_sp_error(n);
}
return Qnil;
}