Messenger - Wrapper for MessagingService

Messenger

Version 0.1.1

Get Messenger :inbox_tray:
View Source :computer:


Messenger is a simple wrapper for Roblox’s MessagingService.

It allows developers to subscribe to an unlimited number of topics (there is a limit with MessagingService). You can also bypass the character limit for topics (which is 80) using Messenger as it has no character limit

I plan to add more features to it in the future.


Example Usage

Below is an example on how to use Messenger, it makes use of all the functions of the current functions of Messenger

local Messenger = require(PATH_TO_MESSENGER)

local Topic = Messenger.new("Example Topic")
Topic:SubscribeAsync(function(message) print(message) end)
Topic:PublishAsync("This message was sent from "..game.JobId,"!")

Cross Server Chat/Messaging Example

Download Example


Thank you!

If you have any suggestions for some features or find any bugs/issues please let me know! :slight_smile:

Licensed under the MIT License

9 Likes

Messenger v0.1.1 - Bug Fix

Fixed bug with type checking (forgot to remove an argument from Messenger.new)

If your using v0.1.0, please update (unless you don’t mind the type warning thing)

1 Like

Can you not just do

local MessagingService = game:GetService("MessagingService")

MessagingService:SubscribeAsync("Example Topic", function(Message) print(Message) end)
MessagingService:PublishAsync("Example Topic", "This message was sent from "..game.JobId.."!")

?

You can but this module has additional features.

You’re able to add an unlimited number of subscriptions (MessagingService limits this to 8 per server I believe) and it also is a tiny bit easier if you have a lot of code doing PublishAsync

Using Messenger the code would be like this:
local Messenger = require(PATH_TO_MESSENGER)

local Topic = Messenger.new("Example Topic") --// only do topic once so you don't need to type it in every time (ex: MessagingService:PublishAsync("Topic") would be typed in tons)
--// publish message on load?
Topic:PublishAsync("Script was loaded!"..game.JobId,"!")

--// do something on event
something.onFakeEvent:Connect(function(something)
    Topic:PublishAsync("something happened?!?!")
end)

--// do something on different event
somethingElse.whenSomethingElseHappens:Connect(function(something)
    Topic:PublishAsync("wow")
end)
Using MessagingService would make the code like this:
--// publish message on load?
MessagingService:PublishAsync("Example Topic", "Script was loaded!"..game.JobId.."!")

--// do something on event
something.onFakeEvent:Connect(function(something)
    MessagingService:PublishAsync("Example Topic","something happened?!?!")
end)

--// do something on different event
somethingElse.whenSomethingElseHappens:Connect(function(something)
    Topic:PublishAsync("Example Topic","wow")
end)

So it saves you a tiny bit of time from needing to repeat “Example Topic” (which would be more annoying on large scripts I’d assume)

Anyways, there will be more features to come in the future which will improve the module.

I don’t think that’s true


There’s no limit for the number of topics as far as I can tell, just how many messages per topic you can receive every minute.

You are correct, however there is a limit to subscribing to topics (which was what I was talking about), which appears to be 8 topics per server.

I tested it below and when it reached the 8th attempt, it threw an error

image

Code used:

for i = 1, 100 do
	print(tostring(i))
	game:GetService("MessagingService"):SubscribeAsync(tostring(i),function() end)
end
1 Like

In the most nicest of ways I genuinely think this has no purpose for any game?

All this will attract is trollers pretending they are roblox or something…

Of course decent project but I actually can’t see a use for it sadly.

I don’t understand what you mean. Have you never used MessagingService before?

Oh sorry please ignore that I have used messaging service lots of time I just saw your example and thought that was the module I genuinely didn’t read I’m ever so sorry.

Oh, it’s fine! I just posted that example so people could see what kind of things it could be used for.

I’m gonna sound like a noob here, but what is a wrapper?

1 Like

It’s basically a script which goes on top of something (for example, an API) and makes it easier to use or adds additional functionality.

For example, I could make a wrapper for the Roblox API which would make it easier for me to send HTTP requests to the API by just making a single function to do that.

So instead of long repetitive code like

local res = game:GetService("HttpService"):GetAsync("random url")

-- do stuff with res

I could just do

wrapper:DoStuffWithRes()
1 Like

Oh, alright! Thanks for answering!

The project looks great, especially the circumvention of the character limit!

1 Like