Developer Documentation
Our new developer documentation is now available. Please check it out!

OdinRoomDataChangedEvent

type OdinRoomDataChangedEvent = (event: IOdinEvent<IOdinRoomDataChangedEventPayload>)

Discussion

The OdinRoomDataChangedEvent event is emitted on OdinRoom instances when the global user data of a room changed by a remote peer.

Events are inheriting from IOdinEvent and provide an object described by IOdinRoomDataChangedEventPayload in the payload property of the event.

Event Scopes

  • IOdinRoomEvents

Example

OdinRoomDataChangedEvent Example
import { OdinClient } from '@4players/odin';

const startOdin = async function (token: string) {
  // Authenticate using a token obtained externally and spawn a room instance
  const odinRoom = await OdinClient.initRoom(token);

  // Adds an event listener to get notified whenever a remote peer updated the global room user data
  odinRoom.addEventListener('UserDataChanged', (event) => {
    console.log('Updated room user data received:', event.payload.room.data);
  });

  // Join the room
  odinRoom.join();
};

startOdin('__YOUR TOKEN__').then(() => {
  console.log('Started ODIN');
});

Parameters

NameTypeDescription
eventIOdinEvent<IOdinRoomDataChangedEventPayload>