About
Echo is a lightweight networking library which initial purpose of is to replicate player related data.
You could say we already got Replica by Loleris which I loved to use and partially inspired of, except it lacked a few features which is why I made this library.
Features
- Data compression: Uses Packet library by Suphi which minimizes network bandwidth usage.
- Replication .Events: Ability to detect replications on both server and client.
- Caching: Received data gets stored which you can later retrieve making data manipulations 100x easier.
- Requests batching: You should expect 0% data loss when it comes to the point, Echo halts replication requests on both client and server and fires in given order afterwards.
Documentation
CONSTRUCTOR
--Returns previously created replicator, or creates a new one.
New(Player : Player, InitialData : {}?) : Replicator?
--Returns a previously created replicator if exists.
FromPlayer(Player : Player) : Replicator?
EVENTS
SERVER
.ReplicatorAdded :: Signal.Signal <Player, Replicator>
.ReplicatorRemoved :: Signal.Signal <Player>
SERVER ECHO
--Returns the listener signal for :SendAll.
.SentAll:: Signal.Signal <any>
CLIENT
.Activated:: Signal.Signal <boolean>
METHODS
SERVER
--Replicates value of the given path. Can pass value manually as 2nd argument, otherwise will get it from the data table.
:Send(Path : {string | number}, Value : any?) : ()
--Returns a previously created listener signal for the path's value, or creates a new one.
:OnSent(Path : {string | number}) : Signal.Signal <any>
--Replicates the data table.
:SendAll() : ()
--Disconnects/clears all cached signals. Destroys the replicator entirely.
:Destroy() : ()
CLIENT
--Launches replications. If called first time will cache up the initial data.
:Start() : boolean
--Halts replications.
:Stop() : boolean
--Returns a boolean, true if client is listening for replications.
:IsActive() : boolean
--Returns the value of the path.
:Get(Path : {string | number}) : any
--Returns a previously created listener signal for the path's value, or creates a new one.
:Receive(Path : Path) : Signal.Signal <NewValue, OldValue>
--Disconnects and clears all receive signals.
:DisconnectAll() : ()
Basic Example
Server
local Echo = require(game.ServerScriptService.EchoServer)
game.Players.PlayerAdded:Connect(function(Player)
local Data = {
Coins = 300,
Wins = 10,
Food = {
Apple = 3,
Coconut = 1,
Banana = 6
}
}
local PlayerEcho = Echo.New(Player, Data)
while true do
Data.Food.Apple += 1
PlayerEcho:Send({"Food", "Apple"}) -- Optionally pass any value you wish
task.wait(1)
end
end)
Client
local Echo = require(game.ReplicatedStorage.EchoClient)
Echo:Start()
Echo:Receive({'Food', 'Apple'}):Connect(function(NewValue : any, OldValue : any)
print("NewValue: ", NewValue, "OldValue: ", OldValue)
end)
Get on Creator Store
Looking for your feedback