blob: c9a9760665cf4a3b0d05408004c18e50c1f06efb (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
package ws
import (
"github.com/spiral/errors"
"github.com/spiral/roadrunner/v2/plugins/broadcast"
"github.com/spiral/roadrunner/v2/plugins/config"
"github.com/spiral/roadrunner/v2/plugins/logger"
)
const (
//
RootPluginName = "broadcast"
//
PluginName = "websockets"
)
type Plugin struct {
// logger
log logger.Logger
// configurer plugin
cfg config.Configurer
}
func (p *Plugin) Init(cfg config.Configurer, log logger.Logger) error {
const op = errors.Op("ws_plugin_init")
// check for the configuration section existence
if !cfg.Has(RootPluginName) {
return errors.E(op, errors.Disabled, errors.Str("broadcast plugin section should exists in the configuration"))
}
p.cfg = cfg
p.log = log
return nil
}
func (p *Plugin) Serve() chan error {
errCh := make(chan error)
return errCh
}
func (p *Plugin) Stop() error {
return nil
}
func (p *Plugin) Name() string {
return PluginName
}
func (p *Plugin) Provides() []interface{} {
return []interface{}{
p.Websocket,
}
}
// Websocket method should provide the Subscriber implementation to the broadcast
func (p *Plugin) Websocket() (broadcast.Subscriber, error) {
const op = errors.Op("websocket_subscriber_provide")
ws, err := NewWSSubscriber()
if err != nil {
return nil, errors.E(op, err)
}
return ws, nil
}
func (p *Plugin) Available(){}
|