mirror of
https://github.com/imezx/Warp.git
synced 2025-04-24 15:10:03 +00:00
v1.0.7
This commit is contained in:
parent
f5bb1df4b0
commit
563af05c62
9 changed files with 102 additions and 5 deletions
BIN
Warp.rbxm
BIN
Warp.rbxm
Binary file not shown.
|
@ -1,5 +1,6 @@
|
|||
--!strict
|
||||
--!native
|
||||
--!optimize 2
|
||||
local Server = {}
|
||||
Server.__index = Server
|
||||
|
||||
|
@ -11,12 +12,16 @@ local ServerProcess = require(script.Parent.ServerProcess)
|
|||
local Assert = require(Util.Assert)
|
||||
local Key = require(Util.Key)
|
||||
local Serdes = require(Util.Serdes)
|
||||
local Buffer = require(Util.Buffer)
|
||||
|
||||
function Server.new(Identifier: string, rateLimit: Type.rateLimitArg?)
|
||||
local self = setmetatable({}, Server)
|
||||
self.id = Serdes(Identifier)
|
||||
self._buffer = Buffer.new()
|
||||
self._buffer:writeu8(Serdes(Identifier))
|
||||
self.id = Buffer.convert(self._buffer:build())
|
||||
self.fn = {}
|
||||
ServerProcess.add(self.id, Identifier, rateLimit or { maxEntrance = 200, interval = 2 })
|
||||
self._buffer:remove()
|
||||
return self
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
--!strict
|
||||
--!native
|
||||
--!optimize 2
|
||||
local Dedicated = {}
|
||||
Dedicated.__index = Dedicated
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
--!strict
|
||||
--!native
|
||||
--!optimize 2
|
||||
local Signal = {}
|
||||
Signal.__index = Signal
|
||||
|
||||
|
|
64
src/Index/Util/Buffer/Dedicated.luau
Normal file
64
src/Index/Util/Buffer/Dedicated.luau
Normal file
|
@ -0,0 +1,64 @@
|
|||
--!strict
|
||||
--!native
|
||||
--!optimize 2
|
||||
local DedicatedBuffer = {}
|
||||
DedicatedBuffer.__index = DedicatedBuffer
|
||||
|
||||
local create = buffer.create
|
||||
local copy = buffer.copy
|
||||
local writeu8 = buffer.writeu8
|
||||
local tostring = buffer.tostring
|
||||
|
||||
local default = {
|
||||
point = 0,
|
||||
size = 256,
|
||||
}
|
||||
|
||||
function DedicatedBuffer.alloc(self: any, byte: number)
|
||||
local size: number = self.size
|
||||
local b: buffer = self.buffer
|
||||
|
||||
while self.point + byte >= size do
|
||||
size = math.floor(size * 1.5)
|
||||
end
|
||||
|
||||
local newBuffer: buffer = create(size)
|
||||
copy(newBuffer, 0, b)
|
||||
|
||||
b = newBuffer
|
||||
end
|
||||
|
||||
function DedicatedBuffer.build(self: any): buffer
|
||||
local p: number = self.point
|
||||
local build: buffer = create(p)
|
||||
|
||||
copy(build, 0, self.buffer, 0, p)
|
||||
return build
|
||||
end
|
||||
|
||||
function DedicatedBuffer.writeu8(self: any, val: number)
|
||||
DedicatedBuffer.alloc(self, 1)
|
||||
writeu8(self.buffer, self.point, val)
|
||||
self.point += 1
|
||||
end
|
||||
|
||||
function DedicatedBuffer.flush(self: any)
|
||||
self.point = default.point
|
||||
self.size = default.size
|
||||
self.buffer = create(256)
|
||||
end
|
||||
|
||||
function DedicatedBuffer.new()
|
||||
return setmetatable({
|
||||
point = default.point,
|
||||
size = default.size,
|
||||
buffer = create(256)
|
||||
}, DedicatedBuffer)
|
||||
end
|
||||
|
||||
function DedicatedBuffer.remove(self: any)
|
||||
self:flush()
|
||||
setmetatable(self, nil)
|
||||
end
|
||||
|
||||
return DedicatedBuffer.new :: typeof(DedicatedBuffer.new)
|
24
src/Index/Util/Buffer/init.luau
Normal file
24
src/Index/Util/Buffer/init.luau
Normal file
|
@ -0,0 +1,24 @@
|
|||
--!strict
|
||||
--!native
|
||||
--!optimize 2
|
||||
local Buffer = {}
|
||||
Buffer.__index = Buffer
|
||||
|
||||
local Dedicated = require(script.Dedicated)
|
||||
|
||||
local tostring = buffer.tostring
|
||||
local fromstring = buffer.fromstring
|
||||
|
||||
function Buffer.new()
|
||||
return Dedicated()
|
||||
end
|
||||
|
||||
function Buffer.convert(b: buffer): string
|
||||
return tostring(b)
|
||||
end
|
||||
|
||||
function Buffer.revert(s: string): buffer
|
||||
return fromstring(s)
|
||||
end
|
||||
|
||||
return Buffer :: typeof(Buffer)
|
|
@ -11,7 +11,8 @@ return function(Identifier: string): string
|
|||
if RunService:IsServer() then
|
||||
if not Event:GetAttribute(Identifier) then
|
||||
SerInt += 1
|
||||
Event:SetAttribute(Identifier, string.pack("I1", SerInt)) -- I1 -> 255 max, I2 -> ~ 6.5e4 max. (SerInt)
|
||||
Event:SetAttribute(Identifier, SerInt)
|
||||
--Event:SetAttribute(Identifier, string.pack("I1", SerInt)) -- I1 -> 255 max, I2 -> ~ 6.5e4 max. (SerInt)
|
||||
end
|
||||
else
|
||||
while not Event:GetAttribute(Identifier) do
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
--!native
|
||||
--!strict
|
||||
--!optimize 2
|
||||
local thread: thread? = nil
|
||||
|
||||
local function passer(fn, ...): ()
|
||||
|
@ -20,7 +21,7 @@ if not thread then
|
|||
coroutine.resume(thread :: any, thread)
|
||||
end
|
||||
|
||||
return function(fn: (...any) -> (), ...: any): ()
|
||||
return function(fn: (...any) -> (...any?), ...: any): ()
|
||||
if not thread then
|
||||
thread = coroutine.create(yield)
|
||||
coroutine.resume(thread :: any, thread)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "imezx/warp"
|
||||
version = "1.0.5"
|
||||
version = "1.0.7"
|
||||
registry = "https://github.com/UpliftGames/wally-index"
|
||||
realm = "shared"
|
||||
license = "MIT"
|
||||
|
|
Loading…
Reference in a new issue