Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-server events #2

Open
rimuy opened this issue Apr 5, 2022 · 0 comments
Open

Cross-server events #2

rimuy opened this issue Apr 5, 2022 · 0 comments
Labels
feature New feature or request

Comments

@rimuy
Copy link
Member

rimuy commented Apr 5, 2022

Would be nice if there was a way to send and receive cross-server events.

Thinking of an API like this:

interface GlobalDefinition<F extends Callback> {
	Connect(callback: F): RBXScriptConnection;
	BroadcastAsync(...args: Parameters<F>): Promise<void>;
	UnicastAsync(jobId: string, ...args: Parameters<F>): Promise<void>;
	MulticastAsync(jobIds: ReadonlyArray<string>, ...args: Parameters<F>): Promise<void>;
	ClientBroadcastAsync(...args: Parameters<F>): Promise<void>;
	ClientUnicastAsync(userId: number, ...args: Parameters<F>): Promise<void>;
	ClientMulticastAsync(userIds: ReadonlyArray<number>, ...args: Parameters<F>): Promise<void>;
}

Where you would declare it like:

new NetBuilder()
	.BindNamespace(
		"Announcement",
		new NetBuilder()
			.BindDefinition(
				new GlobalDefinitionBuilder("Shutdown").SetArguments(t.string).Broadcast().Build()
			)
			.AsNamespace()
	)
	.Build();

And would use it like:

Definitions.CrossServer.Shutdown.Connect((message) => {
	for (const player of Players.GetPlayers()) {
		player.Kick(message);
	}
});

Definitions.CrossServer.Shutdown("hey");
@rimuy rimuy added the feature New feature or request label Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant