summaryrefslogtreecommitdiff
path: root/plugins/websockets
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-06-18 12:00:05 +0300
committerValery Piashchynski <[email protected]>2021-06-18 12:00:05 +0300
commit9e8bad3988c1fec2e545898d529446f7b93e537b (patch)
treed91159b8c78c8add1981641499ef81c821d5d363 /plugins/websockets
parentfe7bb0fe758d573fe353df028257ed66c6eccf66 (diff)
- Rework finished
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/websockets')
-rw-r--r--plugins/websockets/executor/executor.go4
-rw-r--r--plugins/websockets/origin_test.go3
-rw-r--r--plugins/websockets/plugin.go4
-rw-r--r--plugins/websockets/pool/workers_pool.go10
4 files changed, 12 insertions, 9 deletions
diff --git a/plugins/websockets/executor/executor.go b/plugins/websockets/executor/executor.go
index 799312ad..0583be0c 100644
--- a/plugins/websockets/executor/executor.go
+++ b/plugins/websockets/executor/executor.go
@@ -7,12 +7,12 @@ import (
json "github.com/json-iterator/go"
"github.com/spiral/errors"
- "github.com/spiral/roadrunner/v2/pkg/interface/pubsub"
- websocketsv1 "github.com/spiral/roadrunner/v2/pkg/proto/websockets/v1beta"
+ "github.com/spiral/roadrunner/v2/pkg/pubsub"
"github.com/spiral/roadrunner/v2/plugins/logger"
"github.com/spiral/roadrunner/v2/plugins/websockets/commands"
"github.com/spiral/roadrunner/v2/plugins/websockets/connection"
"github.com/spiral/roadrunner/v2/plugins/websockets/validator"
+ websocketsv1 "github.com/spiral/roadrunner/v2/proto/websockets/v1beta"
)
type Response struct {
diff --git a/plugins/websockets/origin_test.go b/plugins/websockets/origin_test.go
index ec6e1960..bbc49bbb 100644
--- a/plugins/websockets/origin_test.go
+++ b/plugins/websockets/origin_test.go
@@ -9,6 +9,7 @@ import (
func TestConfig_Origin(t *testing.T) {
cfg := &Config{
AllowedOrigin: "*",
+ Broker: "any",
}
err := cfg.InitDefault()
@@ -28,6 +29,7 @@ func TestConfig_Origin(t *testing.T) {
func TestConfig_OriginWildCard(t *testing.T) {
cfg := &Config{
AllowedOrigin: "https://*my.site.com",
+ Broker: "any",
}
err := cfg.InitDefault()
@@ -50,6 +52,7 @@ func TestConfig_OriginWildCard(t *testing.T) {
func TestConfig_OriginWildCard2(t *testing.T) {
cfg := &Config{
AllowedOrigin: "https://my.*.com",
+ Broker: "any",
}
err := cfg.InitDefault()
diff --git a/plugins/websockets/plugin.go b/plugins/websockets/plugin.go
index de7443fd..f0b7c6c3 100644
--- a/plugins/websockets/plugin.go
+++ b/plugins/websockets/plugin.go
@@ -10,12 +10,12 @@ import (
"github.com/google/uuid"
json "github.com/json-iterator/go"
"github.com/spiral/errors"
- "github.com/spiral/roadrunner/v2/pkg/interface/broadcast"
- "github.com/spiral/roadrunner/v2/pkg/interface/pubsub"
"github.com/spiral/roadrunner/v2/pkg/payload"
phpPool "github.com/spiral/roadrunner/v2/pkg/pool"
"github.com/spiral/roadrunner/v2/pkg/process"
+ "github.com/spiral/roadrunner/v2/pkg/pubsub"
"github.com/spiral/roadrunner/v2/pkg/worker"
+ "github.com/spiral/roadrunner/v2/plugins/broadcast"
"github.com/spiral/roadrunner/v2/plugins/config"
"github.com/spiral/roadrunner/v2/plugins/http/attributes"
"github.com/spiral/roadrunner/v2/plugins/logger"
diff --git a/plugins/websockets/pool/workers_pool.go b/plugins/websockets/pool/workers_pool.go
index cd9444da..3d95ede0 100644
--- a/plugins/websockets/pool/workers_pool.go
+++ b/plugins/websockets/pool/workers_pool.go
@@ -4,10 +4,10 @@ import (
"sync"
json "github.com/json-iterator/go"
- "github.com/spiral/roadrunner/v2/pkg/interface/pubsub"
- websocketsv1 "github.com/spiral/roadrunner/v2/pkg/proto/websockets/v1beta"
+ "github.com/spiral/roadrunner/v2/pkg/pubsub"
"github.com/spiral/roadrunner/v2/plugins/logger"
"github.com/spiral/roadrunner/v2/plugins/websockets/connection"
+ websocketsv1 "github.com/spiral/roadrunner/v2/proto/websockets/v1beta"
"github.com/spiral/roadrunner/v2/utils"
)
@@ -105,10 +105,10 @@ func (wp *WorkersPool) do() { //nolint:gocognit
}
// res is a map with a connectionsID
- for topic := range res {
- c, ok := wp.connections.Load(topic)
+ for connID := range res {
+ c, ok := wp.connections.Load(connID)
if !ok {
- wp.log.Warn("the user disconnected connection before the message being written to it", "topics", msg.GetTopics()[i])
+ wp.log.Warn("the websocket disconnected before the message being written to it", "topics", msg.GetTopics()[i])
wp.put(res)
continue
}