Joins a user to a room using socket communication with validation checks.

Contains:

  • socket: Socket instance for communication.

  • roomName: Name of the room to join.

  • islevel: User's level indicator.

  • member: User identifier.

  • sec: Security token.

  • apiUserName: API username for authentication.

  • Validation:

    • Ensures roomName, apiUserName, and member are alphanumeric.
    • Verifies that roomName starts with 's' or 'p' and meets length requirements.
    • Validates sec, islevel, and apiUserName against specified length and format conditions.
  • Response Handling:

    • Resolves with the server's response upon a successful join.
    • Rejects with a descriptive error if the user is banned, suspended, or if the host has not yet joined the room.

Resolves with data from the 'joinRoom' event or rejects with validation errors.

Throws errors encountered during validation or join process.

const joinOptions = {
socket: mySocket,
roomName: 'sMyRoom',
islevel: '1',
member: 'participant123',
sec: '64-character-secure-key...',
apiUserName: 'apiUser123',
};
joinRoom(joinOptions)
.then(response => console.log('Room joined:', response))
.catch(error => console.error('Join failed:', error));

Constructors

Methods

Constructors

Methods

  • Joins a user to a specified room via a socket connection.

    Parameters

    Returns Promise<object>

    A promise that resolves with the data received from the 'joinRoom' event or rejects with a validation error.

    Throws an error if the user is banned, suspended, or if the host has not joined the room yet.