github.com/metaworking/channeld@v0.7.3/pkg/channeld/message_debug.go (about) 1 package channeld 2 3 import ( 4 "github.com/metaworking/channeld/pkg/channeldpb" 5 "go.uber.org/zap" 6 ) 7 8 func handleGetSpatialRegionsMessage(ctx MessageContext) { 9 if !GlobalSettings.Development { 10 ctx.Connection.Logger().Error("DebugGetSpatialRegionsMessage can only be handled in Development mode") 11 return 12 } 13 14 if ctx.Channel != globalChannel { 15 ctx.Connection.Logger().Error("illegal attemp to retrieve spatial regions outside the GLOBAL channel") 16 return 17 } 18 19 _, ok := ctx.Msg.(*channeldpb.DebugGetSpatialRegionsMessage) 20 if !ok { 21 ctx.Connection.Logger().Error("mssage is not a DebugGetSpatialRegionsMessage, will not be handled.") 22 return 23 } 24 25 if spatialController == nil { 26 ctx.Connection.Logger().Error("illegal attemp to retrieve spatial regions as there's no controller") 27 return 28 } 29 30 regions, err := spatialController.GetRegions() 31 if err != nil { 32 ctx.Connection.Logger().Error("failed to retrieve spatial regions", zap.Error(err)) 33 } 34 ctx.MsgType = channeldpb.MessageType_SPATIAL_REGIONS_UPDATE 35 ctx.Msg = &channeldpb.SpatialRegionsUpdateMessage{ 36 Regions: regions, 37 } 38 ctx.Connection.Send(ctx) 39 }