From 8b608265772ba5df13d24071117c694bdfd1212a Mon Sep 17 00:00:00 2001 From: xengineering Date: Fri, 30 Jun 2023 13:07:12 +0200 Subject: Add session pointer to routing infrastructure It is nearly useless to route a XML element to an appropriate handler function if the latter has no idea how to send responses to the server or the GUI. Passing a pointer to the session solves this issue. --- xmpp/router.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'xmpp/router.go') diff --git a/xmpp/router.go b/xmpp/router.go index 879579d..bd619b4 100644 --- a/xmpp/router.go +++ b/xmpp/router.go @@ -12,7 +12,7 @@ import ( // entry of the routingTable. type routingTable []struct { name xml.Name - handler func([]xml.Token) + handler func(*session, []xml.Token) } // getRoutingTable returns the routing table used in @@ -29,7 +29,7 @@ func getRoutingTable() routingTable { // route determines the correct handler function for the given XML element by a // given routingTable. In addition it executes the determined handler function. // If no handler function is found an error message is send via the log module. -func route(e []xml.Token, t routingTable) { +func route(s *session, e []xml.Token, t routingTable) { var name xml.Name // TODO a stronger definition of an XML element (as here @@ -50,7 +50,7 @@ func route(e []xml.Token, t routingTable) { for _, r := range t { if name == r.name { - r.handler(e) + r.handler(s, e) return } } -- cgit v1.2.3-70-g09d2