Room
Room
Static Methods
Task<GetRegionsListResponse> GetRegionsListAsync(GetRegionsListOptions options, CancellationToken cancellationToken = null)
Gets the server regions available to host rooms for a Normcore app.
A task that represents the asynchronous operation. The task result contains the regions returned by the matcher.
Events
event ConnectionStateChanged connectionStateChanged
Invoked when the connection state changes. When the state changes to the [Normal.Realtime.Room.ConnectionState.Error](Normal.Realtime.Room.ConnectionState#error) and [Normal.Realtime.Room.ConnectionState.Disconnected](Normal.Realtime.Room.ConnectionState#disconnected) states the subscriber can access the [Normal.Realtime.Room.disconnectEvent](Normal.Realtime.Room#disconnectevent) property to determine the reason.
event RPCMessageReceived rpcMessageReceived
event RoomEventHandler onWillWrite
event RoomEventHandler onWillRead
event RoomEventHandler onDidWrite
event RoomEventHandler onDidRead
Properties
string name { get; }
The name of the room.
bool quickmatchRoom { get; }
Whether the room was created using the Quickmatch backend.
string quickmatchRoomGroupName { get; }
The name of the room group this room belongs to, if it is a Quickmatch room.
string quickmatchRoomCode { get; }
A short code which identifies the room in the room group, if it is a Quickmatch room.
int? quickmatchRoomCapacity { get; }
The number of clients that can be simultaneously connected to the room, if it is a Quickmatch room.
RegionMetadata? region { get; }
The server region the room is hosted in.
This will be null until connected to the server.
int clientID { get; }
The ID of the local client on the server.
This will be -1 until connected to the server.
double time { get; }
The server time on this frame in unix epoch time format (seconds since 00:00:00 UTC on January 1, 1970).
This value can be used to drive animations and is backed by a monotonic clock with sub-millisecond precision. This value has latency from the server removed.
DateTime? dateTime { get; }
The server date and time on this frame (UTC).
This value can be used to drive day/night cycles, for example. It is directly derived from . Will be null when the room is not yet in the state.
float ping { get; }
The local client's last known ping with the server in milliseconds.
ConnectionState connectionState { get; }
The connection state of the room.
DisconnectEvent disconnectEvent { get; }
The disconnect data for the last disconnect event. Access only within the [Normal.Realtime.Room.connectionStateChanged](Normal.Realtime.Room#connectionstatechanged) callback for [Normal.Realtime.Room.ConnectionState.Error](Normal.Realtime.Room.ConnectionState#error) and [Normal.Realtime.Room.ConnectionState.Disconnected](Normal.Realtime.Room.ConnectionState#disconnected).
bool connecting { get; }
True if the room is connecting to the server.
bool connected { get; }
True if the room is connected to the server.
bool disconnected { get; }
True if the room is disconnected or in an error state.
bool offlineMode { get; }
True if the client was started in offline mode with no networking capabilities.
double datastoreFrameDuration { get; set; }
bool debugLogging { get; set; }
Component realtime { get; set; }
Datastore datastore { get; }
Methods
void Dispose()
void Connect(string roomName, ConnectOptions connectOptions)
Connect to a room.
void ConnectDirectlyToQuickmatchRoom(string roomGroupName, string roomCode, ConnectOptions connectOptions)
Connect to an existing Quickmatch room.
void ConnectToNextAvailableQuickmatchRoom(string roomGroupName, int capacity, ConnectOptions connectOptions)
Connect to a room using Quickmatch.
The client will connect to a room in the Quickmatch room group that has remaining capacity. If all rooms in the room group are full, the client connects to a new room added to the room group. When searching for remaining capacity, the capacity specified when each room was originally added is used. Therefore, if the client is connected to an existing room, the capacity of the room may be different from the requested capacity. To reconnect to a Quickmatch room, store the after the room is first connected and use ConnectDirectlyToQuickmatchRoom() with that room code later. However, reconnecting is not guaranteed, as the room may be filled with new clients before the reconnect is initiated.
void Disconnect()
Disconnect from the room.
void Tick(double deltaTime)
bool SendRPCMessage(byte[] data, bool reliable)
bool SendRPCMessage(byte[] data, int dataLength, bool reliable)
AudioInputStream CreateAudioInputStream(bool voice, int sampleRate, int channels)
AudioOutputStream GetAudioOutputStream(int clientID, int streamID)
ConnectionStatistics? GetConnectionStatistics(ChannelFlags channels = All)
Gets the connection statistics for the room.
This can be used to monitor the quality of the connection to the server. Connection statistics are not available in WebGL builds.
The connection statistics for the specified channels. Will be until connected and the first batch of statistics is collected, or when in a WebGL build.