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

iris mvc use r3labs/sse #96

Closed
WyntersN opened this issue Sep 30, 2021 · 1 comment
Closed

iris mvc use r3labs/sse #96

WyntersN opened this issue Sep 30, 2021 · 1 comment

Comments

@WyntersN
Copy link

need iris mvc use r3labs/sse examples

@WyntersN
Copy link
Author

WyntersN commented Sep 30, 2021

common.go

var Sse = sse.New()

func init() {
	Sse.CreateStream("messages")
}

func SsePublish(id string, str string) {
	Sse.Publish(id, &sse.Event{
		Data: []byte(str),
	})
}

route.go

mvc.New(app.Party("/api/sse", iris.FromStd(common.Sse.HTTPHandler))).
		Register(api.SessManager.Start).
		Handle(new(v1App.AppSseController))

AppSseController.go

type AppSseController struct {
	api.AppController
}

func (c *AppSseController) Get(b mvc.BeforeActivation) {
	c.Ctx.Next()
	common.SsePublish("messages", "pingaaa")
	c.Ctx.Next()
	app.Events(c.Ctx)
}

no return sse data "pingaaa"

@WyntersN WyntersN closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant