muc: consider making handling messages easier #245

Open
opened 2022-01-26 12:50:22 +00:00 by SamWhited · 0 comments

Right now when handling MUC messages we're requiring that the user create their own handler and have it check if a message is to an address that's also an open MUC channel. Eg. they have to register something like this on the muc and do a lot of work:

mux.Message(stanza.GroupChatMessage, xml.Name{Local: "body"}, yourMessageHandler)

Instead, we should investigate other design possibilities. One that should be investigated is whether or not it's possible to have a muc.MessageHandler or similar that gets added to the muc.Client and if non-nil muc.HandleClient will handle registering a handler that calls the message handler, passing in the matching channel. Eg. something like this:

type Client struct {

	// HandleInvite will be called if we receive a mediated MUC invitation.
	HandleInvite       func(Invitation)
	HandleUserPresence func(stanza.Presence, Item)
        HandleMessage func(Channel, MessageHandler) 
	// contains filtered or unexported fields
}

A more detailed proposal should be written up, or more discussion should probably happen before this is implemented.

Right now when handling MUC messages we're requiring that the user create their own handler and have it check if a message is to an address that's also an open MUC channel. Eg. they have to register something like this on the muc and do a lot of work: ```go mux.Message(stanza.GroupChatMessage, xml.Name{Local: "body"}, yourMessageHandler) ``` Instead, we should investigate other design possibilities. One that should be investigated is whether or not it's possible to have a `muc.MessageHandler` or similar that gets added to the `muc.Client` and if non-nil `muc.HandleClient` will handle registering a handler that calls the message handler, passing in the matching channel. Eg. something like this: ```go type Client struct { // HandleInvite will be called if we receive a mediated MUC invitation. HandleInvite func(Invitation) HandleUserPresence func(stanza.Presence, Item) HandleMessage func(Channel, MessageHandler) // contains filtered or unexported fields } ``` A more detailed proposal should be written up, or more discussion should probably happen before this is implemented.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mellium/xmpp#245
There is no content yet.