blob: 660efdcaaeccb7a8c3b281d8a612380bb9a223ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package ws
import (
"github.com/gofiber/fiber/v2"
"github.com/spiral/roadrunner/v2/plugins/broadcast"
"github.com/spiral/roadrunner/v2/plugins/broadcast/ws/connection"
)
type Subscriber struct {
connections map[string]*connection.Connection
storage broadcast.Storage
}
// config
//
func NewWSSubscriber(storage broadcast.Storage) (broadcast.Subscriber, error) {
m := make(map[string]*connection.Connection)
go func() {
app := fiber.New()
app.Use("/ws", wsMiddleware)
app.Listen(":8080")
}()
return &Subscriber{
connections: m,
storage: storage,
}, nil
}
func (s *Subscriber) Subscribe(topics ...string) error {
panic("implement me")
}
func (s *Subscriber) SubscribePattern(pattern string) error {
panic("implement me")
}
func (s *Subscriber) Unsubscribe(topics ...string) error {
panic("implement me")
}
func (s *Subscriber) UnsubscribePattern(pattern string) error {
panic("implement me")
}
func (s *Subscriber) Publish(messages ...*broadcast.Message) error {
s.storage.GetConnection(messages[9].Topic)
return nil
}
|