{"id":"reimakesgames/link","name":"link","scope":"reimakesgames","platform":"roblox","description":"Mirrored from the Wally registry.","version":"0.3.0","latest":"0.3.0","versions":["0.1.0","0.2.0","0.2.1","0.2.2","0.2.3","0.2.4","0.3.0"],"license":"BSD-3-Clause","licenseRating":"safe","licenseCaveats":["The copyright notice must be preserved in copies. The author's name may not be used to promote your product.","License identified from the packaged LICENSE file; the manifest declared none."],"licenseVerified":true,"dependencies":{"lucasmzreal/fastsignal":{"version":"^10.2.1","alias":"fastsignal"}},"integrity":"6cb7ceed48762697f4f2191dc839774230c1545ff739fa3290b41f22be220f45","likes":0,"downloads":0,"install":"forest install reimakesgames/link","url":"https://forest.dev/p/roblox/reimakesgames/link","files":"https://api.forest.dev/ai/package/roblox/reimakesgames/link/files","readme":"# Link\r\nA simplistic, close to Roblox, RemoteEvent/RemoteFunction wrapper.\r\n\r\n## Why Link?\r\nLink is an easily extensible networking wrapper.\r\nIt can support middleware to enable features like serialization and deserialization, without the need to complicate your inputted data.\r\n\r\n## Features\r\n<!-- * Middleware(s) -->\r\n<!-- * Serialization -->\r\n<!-- * Deserialization -->\r\n* Basic RemoteEvent/RemoteFunction features\r\n* Pseudo-remotes to allow easier VSCode integration\r\n\r\n# API\r\n## Link\r\n\r\n### Link:CreateEvent(name: *string*): *[EventLink](#connection)*\r\nCreates a new Event.\r\n```lua\r\nlocal ExampleEvent = Link:CreateEvent(\"Event\")\r\n```\r\n\r\n### Link:FindEvent(name: *string*):  *[EventLink](#connection) | nil*\r\nFinds the event within the Connections table. Returns nil if not found. <br>\r\nWorks similarly to `Instance:FindFirstChild`.\r\n```lua\r\nlocal ExampleEvent = Link:FindEvent(\"EventName\")\r\n```\r\n\r\n### Link:WaitEvent(name: *string*, timeout: *number?*): *[EventLink](#connection)*\r\nWaits for the event in the Connections table.\r\n> This method yields the current thread until the event is found.\r\n\r\n```lua\r\nlocal ExampleEvent = Link:WaitEvent(\"EventName\")\r\nlocal ExampleEvent = Link:WaitEvent(\"EventName\", 5)\r\n```\r\n\r\n### Link:CreateFunction(name: *string*): *[FunctionLink](#connection)*\r\nCreates a new Function.\r\n```lua\r\nlocal ExampleFunction = Link:CreateFunction(\"Function\")\r\n```\r\n\r\n### Link:FindFunction(name: *string*): *[FunctionLink](#connection) | nil*\r\nFinds the function within the Connections table. Returns nil if not found. <br>\r\nWorks similarly to `Instance:FindFirstChild`.\r\n```lua\r\nlocal ExampleFunction = Link:FindFunction(\"FunctionName\")\r\n```\r\n\r\n### Link:WaitFunction(name: *string*, timeout: *number?*): *[FunctionLink](#connection)*\r\nWaits for the function in the Connections table.\r\n> This method yields the current thread until the function is found.\r\n\r\n```lua\r\nlocal ExampleFunction = Link:WaitFunction(\"FunctionName\")\r\nlocal ExampleFunction = Link:WaitFunction(\"FunctionName\", 5)\r\n```\r\n\r\n### Link:Connections: { [*string*]: *[EventLink](#connection)* | *[FunctionLink](#connection)* }\r\n\r\nThe dictionary where the connections are stored\r\n\r\nexample:\r\n| Key | Value |\r\n| ---- | ---- |\r\n| Prefix_Name_Suffix | [EventLink](#connection) |\r\n| REMOTE_Name | [FunctionLink](#connection) |\r\n\r\n<!-- </details> -->\r\n\r\n## Event\r\n\r\n### EventLink:FireClient(player: *Player*, ...*any*): *nil*\r\n> Server -> Client\r\n\r\nFires the event to the specified player.\r\n```lua\r\nlocal ExampleEvent = Link:CreateEvent(\"Event\")\r\nExampleEvent:FireClient(player, \"Hello\", \"World\")\r\n```\r\n\r\n### EventLink:FireAllClients(...*any*): *nil*\r\n> Server -> All Clients\r\n\r\nFires every player within the game\r\n```lua\r\nlocal ExampleEvent = Link:CreateEvent(\"Event\")\r\nExampleEvent:FireAllClients(\"Hello\", \"World\")\r\n```\r\n\r\n### EventLink:FireClients(selectedPlayers: *Array\\<Players\\>*, ...*any*): *nil*\r\n> Server -> Selected Clients\r\n\r\nFires the selected players within the array\r\n```lua\r\nlocal ExampleEvent = Link:CreateEvent(\"Event\")\r\nExampleEvent:FireClients({player1, player2}, \"Hello\", \"World\")\r\n```\r\n\r\n### EventLink:FireClientsExcept(excludedPlayers: *Array\\<Players\\>*, ...*any*): *nil*\r\n> Server -> All Clients Except Selected\r\n\r\nFires every player within the game, except the selected players within the array\r\n```lua\r\nlocal ExampleEvent = Link:CreateEvent(\"Event\")\r\nExampleEvent:FireClientsExcept({player1, player2}, \"Hello\", \"World\")\r\n```\r\n\r\n### EventLink:FireServer(...*any*): *nil*\r\n> Client -> Server\r\n\r\nFires to the server with the provided parameters\r\n```lua\r\nlocal ExampleEvent = Link:WaitEvent(\"Event\")\r\nExampleEvent:FireServer(\"Hello\", \"World\")\r\n```\r\n\r\n### EventLink.Event: *[FastSignal.Class](https://github.com/RBLXUtils/FastSignal/blob/main/src/ReplicatedStorage/FastSignal/Deferred.lua#L26-L29)*\r\nEvent you can connect to.\r\n\r\n```lua\r\nlocal Event = Link:CreateEvent(\"Event\")\r\nExampleEvent.Event:Connect(function(...)\r\n\tprint(...)\r\nend)\r\n```\r\n\r\n## Function\r\n\r\n### FunctionLink:InvokeClient(player: *Player*, ...*any*): *any*\r\n> Server -> Client <br>\r\nYields\r\n\r\nConsidered by Roblox as unsafe. Use with caution. <br>\r\nInvokes the specified player with the provided parameters.\r\n```lua\r\nlocal ExampleFunction = Link:CreateFunction(\"Function\")\r\nlocal result = ExampleFunction:InvokeClient(player, \"Hello\", \"World\")\r\n```\r\n### FunctionLink:InvokeServer(...*any*): *any*\r\n> Client -> Server <br>\r\nYields\r\n\r\nInvokes the server with the provided parameters.\r\n```lua\r\nlocal ExampleFunction = Link:WaitFunction(\"Function\")\r\nlocal result = ExampleFunction:InvokeServer(\"Hello\", \"World\")\r\n```\r\n\r\n### FunctionLink:OnClientInvoke(callback: (...*any*) -> *any*): *nil*)\r\n> Similar to RemoteFunction.OnClientInvoke\r\n\r\nA setter for the OnClientInvoke callback which is called when the server invokes the client.\r\n```lua\r\nlocal ExampleFunction = Link:CreateFunction(\"Function\")\r\nExampleFunction:OnClientInvoke(function(...)\r\n\tprint(...)\r\n\treturn true\r\nend)\r\n```\r\n\r\n### FunctionLink:OnServerInvoke(callback: (player: Player, ...*any*) -> *any*): *nil*)\r\n> Similar to RemoteFunction.OnServerInvoke\r\n\r\nA setter for the OnServerInvoke callback which is called when the client invokes the server.\r\n```lua\r\nlocal ExampleFunction = Link:CreateFunction(\"Function\")\r\nExampleFunction:OnServerInvoke(function(player, ...)\r\n\tprint(\"Player\", player.Name, \"invoked the server with\", ...)\r\n\treturn true\r\nend)\r\n```\r\n","readmeTruncated":false}