xmppRoomJoin()

This function allows you to join a chat room.

Synopsis

int xmppRoomJoin(int clientId, string room [, string nickname [, mapping options]]);

Parameter

Parameter Description
clientid The unique client id for the client channel. The id is returned by the xmppOpen() function.
room

The room name. When a room does not exist yet, it will be created (if the server allows you to create a room ).

If no further options are given, the room will be created as a temporary room ("instant room" in XMPP terminology), which will be deleted by the server when the last participant leaves.

nickname In nickname you can set the name that is displayed to other users for this room. The default nickname is the user name part of the jid.
options

The options mapping can have the following keys:

Note however that it depends on the server if it implements an option. If an option is not available, an error for this option is printed and it is ignored.

password (string): The password needed to join the room if the room is password protected. If the room does not exist yet and is created, this password defines the required password for other users to join.

persistent (bool): If this parameter is true, the room is kept on the server even when there are no participants. This parameter also keeps the owner status for the creator of the room.

public (bool): If this parameter is true it makes a room publicly searchable .

allowInvites (bool): If this parameter is true, it allows participants to invite others.

maxHistoryFetch (int): Maximum Number of history messages returned by a room

description (string): Description of the room.

name (string): Natural-Language Room Name

Return Value

Returns 0 when the function was successfully executed or -1 in case of errors

Errors

Errors can be queried via getLastError().

Description

This function allows you to join a chat room.

The following example allows the user winccoa.etm to enter a chat room.

Note: You have to replace the code: p = xmppOpen("winccoa.etm@jabber.at","123677", "callback", m); DebugN("xmppOpen:", p); by your own user and password. This code is an example!
#uses "CtrlXmpp"
int p;
main(mapping event)
{
  mapping m;
  int port;
  string host;
  string resource;
  bool autoAcceptSubscriptions = FALSE;
  string logging;
  m["host"]= host;
  m["port"] = port;
  m["resource"] = resource;
  m["autoAcceptSubscriptions"] = autoAcceptSubscriptions;
  m["logging"] = "send";
  p = xmppOpen("winccoa.etm@jabber.at","123677");
  DebugN("xmppOpen:", p);
  int s = xmppRoomJoin(p,"testraum@conference.jabber.at", "WinCCOA");
  DebugN("Joined the room:", s);
}
Figure 1. The user winccoa.etm with the nickname "WinCCOA" in the room testraum

Assignment

XMPP functions

Availability

CTRL

See also

xmppOpen(), xmppClose()