Class Server

A server replicator for VirtualValue.

A Server handles replication of a VirtualValue to/from players with specific Permissions. A Client is used to communicate with a server. The following protocols are used:

  • Event: Implemented using RemoteEvent. Represents some data that a server sends to one or more clients.
  • Command: Implemented using RemoteFunction. Represents a single query by a client who usually has some permission.

The different kinds of events and commands are described in Constants. A server has two states:

  • Closed: Starting state. Server rejects all commands and emits no events.
  • Open: Server will respond to commands and emit events, such as when the VirtualValue changes.

On construction, a Server creates a remotes container using the Remotes utility. This container can be gotten using getRemotesContainer and should be named/parented somewhere accessible to clients. The remotes container should be passed to Client.new. The container is destroyed when the server is cleaned up.

Methods

Server:new(virtualValue[, allowRead]) Create a new server that replicates the value contained in virtualValue
Server:cleanup() Closes the server (if open) and releases all resources used
Server:getVirtualValue() Returns the VirtualValue whose value this server is replicating
Server:getRemotesContainer() Returns an object which returns the remotes container in use by this server.
Server:setRemotesContainerParentName(newParent[, newName]) Convenience function for setting the remotes container parent and name properties
Server:isOpen() Returns whether the server is open
Server:assertOpen() Asserts whether the server Server:isOpen
Server:open() Opens the server, immediately replicating the value
Server:close() Closes the server
Server:replicateValue() Replicates the present values to everyone with "Read".


Methods

Server:new(virtualValue[, allowRead])
Create a new server that replicates the value contained in virtualValue

Parameters:

  • virtualValue VirtualValue The value to replicate
  • allowRead boolean Whether the Server should grant read permissions to all players (optional)
Server:cleanup()
Closes the server (if open) and releases all resources used
Server:getVirtualValue()
Returns the VirtualValue whose value this server is replicating

Returns:

    VirtualValue
Server:getRemotesContainer()
Returns an object which returns the remotes container in use by this server. Should be passed to Client.new.

Returns:

    The remotes container
Server:setRemotesContainerParentName(newParent[, newName])
Convenience function for setting the remotes container parent and name properties

Parameters:

  • newParent The new parent object for the remotes container
  • newName string The name for the remotes container (optional)
Server:isOpen()
Returns whether the server is open
Server:assertOpen()
Asserts whether the server Server:isOpen
Server:open()
Opens the server, immediately replicating the value
Server:close()
Closes the server
Server:replicateValue()
Replicates the present values to everyone with "Read". Server must be open.
generated by LDoc 1.4.6 Last updated 2021-01-21 07:22:00