Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# .github/workflows/publish-docs.yml
name: publish-docs
on:
push:
branches: ["master"]
jobs:
status:
runs-on: ubuntu-latest
name: Publish docs to GitHub Pages
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- run: npm i -g moonwave@latest
- name: Publish
run: |
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git config --global user.email "support+actions@github.com"
git config --global user.name "github-actions-bot"
moonwave build --publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"[luau]": {
"editor.defaultFormatter": "JohnnyMorganz.stylua",
"editor.formatOnSave": true
}
}
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Networker
A complete replacement for RemoteEvents
A complete replacement for RemoteEvents allowing you to modify tables and call functions on a different run context effortlessly

# Server
## Examples

```luau
### Server

```lua
local myService = {}

function myService:init()
Expand All @@ -25,12 +27,12 @@ end
return myService
```

# Client
### Client

```luau
```lua
local serviceClient = {}

local networker = Networker.client.new("myService", serviceClient)
networker:fire("printTest")
networker:fire("printTest") -- tell the server to call the printTest function

```
22 changes: 22 additions & 0 deletions docs/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
sidebar_position: 1
---

# Installation

## Wally

Add [leifstout/networker](https://wally.run/package/leifstout/networker?version=0.3.0) to your Wally configuration file.

<sub>wally.toml</sub>
```toml
[package]
name = "username/game"
description = "An awesome game!"
version = "0.1.0"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"

[dependencies]
networker = "leifstout/networker@0.3.0"
```
73 changes: 73 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
sidebar_position: 2
---

# Basic Usage
Networker allows you to call certain select server functions on the client. To start, you must create a *Networker.server* object

<sub>main.server.luau</sub>

```lua
local Networker = require("path/to/networker")

local module = {}

local function module.printSomething(
self: typeof(module) -- networker always returns the module itself as the first parameter
player: Player, -- always the second parameter, the player who fired the function
... -- arguments that the player sent
)
print(`{player.Name} said "{...}"!`)
end

-- create a server networker object
local networker = Networker.server.new(
"myScript", -- unique identifier
module, -- the module that the client will communicate with
{ -- functions from the module which the client can access
printSomething,
}
)


-- tell all clients to call the setValue function with a 50 parameter
networker:fireAll("setValue", 50)

-- OR

networker:setAll("myValue", 50)
```
You must then create a *Networker.client* object

<sub>main.client.luau</sub>

```lua
local Networker = require("path/to/networker")

local myClientModule = {
myValue = 0
}

function myClientModule.setValue(self: typeof(myClientModule), value: number)
self.myValue = value
end

-- create a client networker object
local networker = Networker.client.new(
"myScript", -- same identifier we used on the server
myClientModule -- module that the server can communicate with
)

-- check when the server sets a value using :set or :setAll
networker:getServerChangedSignal(
"myValue" -- key name
):Connect(function(newVal)
print(`server set myValue to: {newVal}!`)
end)

-- tell the server to call the printSomething function with a "Hello there!" parameter
networker:fire(
"printSomething", -- function name
"Hello there!"
)
```
27 changes: 27 additions & 0 deletions moonwave.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
gitSourceBranch = "main"

[[navbar.items]]
href = "https://discord.com/invite/r3rVDatP7x"
label = "Discord"
position = "right"

[[navbar.items]]
href = "https://wally.run/package/leifstout/networker"
label = "Wally"
position = "right"

[home]
enabled = true
includeReadme = false

[[home.features]]
title = "Ease of Use"
description = "Networker abstracts RemoteEvents and RemoteFunctions behind a clean, method-based API."

[[home.features]]
title = "Selective Replication"
description = "Messages can be sent to players based on many different conditions."

[[home.features]]
title = "Battle Tested"
description = "Used in projects with 10M+ visits and 200K+ MAU"
7 changes: 5 additions & 2 deletions src/NetworkerClient.luau
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type RemotesContainer = NetworkerUtils.RemotesContainer
--[=[
NetworkerClient facilitates the communication of client-sided networking and handles server networking instructions
@class NetworkerClient
@client
]=]
local NetworkerClient = {}
NetworkerClient.__index = NetworkerClient
Expand All @@ -26,8 +27,8 @@ export type NetworkerClient = typeof(setmetatable(
))

--[=[
Constructs a new NetworkerClient
@param networkTag NetworkTag -- The unqiue tag of the networker
Constructs a new NetworkerClient
@param networkTag NetworkTag -- The unique tag of the networker
@param module {} -- The class or service the networker will be communicating with
@return NetworkerClient
]=]
Expand Down Expand Up @@ -135,4 +136,6 @@ function NetworkerClient.destroy(self: NetworkerClient): ()
end
end

NetworkerClient.Destroy = NetworkerClient.destroy

return NetworkerClient
4 changes: 4 additions & 0 deletions src/NetworkerServer.luau
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type RemotesContainer = NetworkerUtils.RemotesContainer
--[=[
NetworkerServer facilitates the communication of server-sided networking and handles client networking requests
@class NetworkerServer
@server
]=]
local NetworkerServer = {}
NetworkerServer.__index = NetworkerServer
Expand Down Expand Up @@ -292,4 +293,7 @@ function NetworkerServer.destroy(self: NetworkerServer): ()
end
end

-- Alias for :destroy()
NetworkerServer.Destroy = NetworkerServer.destroy

return NetworkerServer