Skip to content

A crosswalk shared module to send data from the server to clients

License

Notifications You must be signed in to change notification settings

seaofvoices/crosswalk-channels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

checks version GitHub top language license npm

Channels

A crosswalk shared module to easily send data one way from the server to client(s). Values can be sent to individual players or to all players.

IMPORTANT

This module will make use of PlayerGui to store instances, so to prevent them from being deleted when the character reloads, you must disable the ResetPlayerGuiOnSpawn property of StarterGui. Disable this property by running this line in the command bar:

game.StarterGui.ResetPlayerGuiOnSpawn = false

Installation

Using the npm package

Add crosswalk-channels in your dependencies:

yarn add crosswalk-channels

Or if you are using npm:

npm install crosswalk-channels

Roblox asset

Put the Channels.rbxm file inside your crosswalk shared modules folder.

License

This plugin for crosswalk is available under the MIT license. See LICENSE.txt for details.

API

Server API

Send

Publish values on a channel that any player can listen to.

Channels.Send(channelName: string, value: unknown)

SendLocal

Publish values on a channel for a single player.

Channels.SendLocal(player: Player, channelName: string, value: unknown)

Bind

Listen for changes on a channel (using Channels.Send).

Bind<T>(channelName: string, func: (T) -> ()): () -> ()
  • Listen to data sent on global signals (sent to all players with Send).
  • The returned function disconnects from the channel

BindPlayer

Listen for changes on a local channel (using Channels.SendLocal).

BindPlayer<T>(channelName: string, func: (Player, T) -> ()): () -> ()
  • Listen to data sent on local signals (sent to individual players with SendLocal).
  • The returned function disconnects from the channel

Client API

Bind

Listen for changes on a channel.

Bind<T>(channelName: string, func: (T) -> ()): () -> ()
  • Each client can connect to values that are sent to its own player or to all players.
  • The returned function disconnects from the channel
local disconnect = Channels.Bind("timer", function(newValue)

end)

-- ... when needed, you can disconnect the callback by calling the `disconnect` function

disconnect()