Skip to content

Commit

Permalink
(update): Update engine.io version.
Browse files Browse the repository at this point in the history
  • Loading branch information
zishang520 committed Nov 1, 2023
1 parent aa3bf65 commit 696aba0
Show file tree
Hide file tree
Showing 15 changed files with 462 additions and 394 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ The following example attaches socket.io to a plain engine.io *types.CreateServe
package main

import (
"github.com/zishang520/engine.io/types"
"github.com/zishang520/engine.io/utils"
"github.com/zishang520/engine.io/v2/types"
"github.com/zishang520/engine.io/v2/utils"
"github.com/zishang520/socket.io/v2/socket"
"os"
"os/signal"
Expand Down
24 changes: 18 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
module github.com/zishang520/socket.io/v2

go 1.20
go 1.21

require (
github.com/andybalholm/brotli v1.0.5
github.com/andybalholm/brotli v1.0.6
github.com/mitchellh/mapstructure v1.5.0
github.com/zishang520/engine.io v1.5.9
github.com/zishang520/engine.io-go-parser v1.2.2
github.com/zishang520/socket.io-go-parser v1.0.4
github.com/zishang520/engine.io-go-parser v1.2.3
github.com/zishang520/engine.io/v2 v2.0.0
github.com/zishang520/socket.io-go-parser/v2 v2.0.0
)

require (
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/onsi/ginkgo/v2 v2.12.0 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
github.com/quic-go/quic-go v0.40.0 // indirect
github.com/quic-go/webtransport-go v0.6.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
go.uber.org/mock v0.3.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
)
59 changes: 49 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,36 +1,75 @@
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk=
github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f h1:pDhu5sgp8yJlEF/g6osliIIpF9K4F5jvkULXa4daRDQ=
github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI=
github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ=
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs=
github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
github.com/quic-go/quic-go v0.40.0 h1:GYd1iznlKm7dpHD7pOVpUvItgMPo/jrMgDWZhMCecqw=
github.com/quic-go/quic-go v0.40.0/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpTx31vx60c=
github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFDD3NxaZLY=
github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
github.com/zishang520/engine.io v1.5.9 h1:MkV5/nMrT5N7uFygo3XC08BUiiwb8T29q/uM7aMZcj4=
github.com/zishang520/engine.io v1.5.9/go.mod h1:dwVIHU7gj3y8aDZexDrcDDIh1eKd4BjP5LdTgId6Lck=
github.com/zishang520/engine.io-go-parser v1.2.2 h1:EeebzZwJ/798RO78Q0Mi66ZP4SRpIjEgQSCvcToVTKM=
github.com/zishang520/engine.io-go-parser v1.2.2/go.mod h1:YBIkLpDtU5PXpNMM0cUPX5GUY9Zyo2W1sEwKMbk2WY4=
github.com/zishang520/socket.io-go-parser v1.0.4 h1:YI8fYHkPcBthJ85mqIAGIoG0FjvjRDLtkGZGeJfVim0=
github.com/zishang520/socket.io-go-parser v1.0.4/go.mod h1:MH46HoC+N5yNUljfqw8InofX1Ao4Fuok3K7UrzjaVR4=
github.com/zishang520/engine.io-go-parser v1.2.3 h1:y++zdMKIFgyVvH60TEEHw8gdJkS/qy22wesdALoh+HA=
github.com/zishang520/engine.io-go-parser v1.2.3/go.mod h1:UrXBVZWQgyHDITYmhnxi2d+NpEWBN8dACboD4dXcx38=
github.com/zishang520/engine.io/v2 v2.0.0 h1:G+Y1hU58OpXzHLt1jZ4Y1v3qF6ZOLkqp0+sQQfNKINg=
github.com/zishang520/engine.io/v2 v2.0.0/go.mod h1:HM5pZZMFI/dNNmuwePLsaiGM67VY6vxJ5Isp+QRylMU=
github.com/zishang520/socket.io-go-parser/v2 v2.0.0 h1:/wggJ+xE225CzcPooJ1dGBmJ5qGtIQV+YxajwRqg5w4=
github.com/zishang520/socket.io-go-parser/v2 v2.0.0/go.mod h1:9X2iU65lng09e3Dg4t0nrAuMuzvSVJwb0mPL0UBERsg=
go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo=
go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 h1:Vve/L0v7CXXuxUmaMGIEK/dEeq7uiqb5qBgQrZzIE7E=
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
97 changes: 49 additions & 48 deletions socket/adapter-type.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,68 @@ import (
"time"

"github.com/zishang520/engine.io-go-parser/packet"
"github.com/zishang520/engine.io/types"
"github.com/zishang520/engine.io/v2/types"
)

// A public ID, sent by the server at the beginning of the Socket.IO session and which can be used for private messaging
type SocketId string
type (
// A public ID, sent by the server at the beginning of the Socket.IO session and which can be used for private messaging
SocketId string

// A private ID, sent by the server at the beginning of the Socket.IO session and used for connection state recovery
// upon reconnection
type PrivateSessionId string
// A private ID, sent by the server at the beginning of the Socket.IO session and used for connection state recovery
// upon reconnection
PrivateSessionId string

// we could extend the Room type to "string | number", but that would be a breaking change
// Related: https://github.com/socketio/socket.io-redis-adapter/issues/418
type Room string
// we could extend the Room type to "string", but that would be a breaking change
// Related: https://github.com/socketio/socket.io-redis-adapter/issues/418
Room string

type WriteOptions struct {
packet.Options
WriteOptions struct {
packet.Options

Volatile bool `json:"volatile" mapstructure:"volatile" msgpack:"volatile"`
PreEncoded bool `json:"preEncoded" mapstructure:"preEncoded" msgpack:"preEncoded"`
WsPreEncoded string `json:"wsPreEncoded" mapstructure:"wsPreEncoded" msgpack:"wsPreEncoded"`
}
Volatile bool `json:"volatile" mapstructure:"volatile" msgpack:"volatile"`
WsPreEncoded string `json:"wsPreEncoded" mapstructure:"wsPreEncoded" msgpack:"wsPreEncoded"`
}

type BroadcastFlags struct {
WriteOptions
BroadcastFlags struct {
WriteOptions

Local bool `json:"local" mapstructure:"local" msgpack:"local"`
Broadcast bool `json:"broadcast" mapstructure:"broadcast" msgpack:"broadcast"`
Binary bool `json:"binary" mapstructure:"binary" msgpack:"binary"`
Timeout *time.Duration `json:"timeout,omitempty" mapstructure:"timeout,omitempty" msgpack:"timeout,omitempty"`
Local bool `json:"local" mapstructure:"local" msgpack:"local"`
Broadcast bool `json:"broadcast" mapstructure:"broadcast" msgpack:"broadcast"`
Binary bool `json:"binary" mapstructure:"binary" msgpack:"binary"`
Timeout *time.Duration `json:"timeout,omitempty" mapstructure:"timeout,omitempty" msgpack:"timeout,omitempty"`

ExpectSingleResponse bool `json:"expectSingleResponse" mapstructure:"expectSingleResponse" msgpack:"expectSingleResponse"`
}
ExpectSingleResponse bool `json:"expectSingleResponse" mapstructure:"expectSingleResponse" msgpack:"expectSingleResponse"`
}

type BroadcastOptions struct {
Rooms *types.Set[Room] `json:"rooms,omitempty" mapstructure:"rooms,omitempty" msgpack:"rooms,omitempty"`
Except *types.Set[Room] `json:"except,omitempty" mapstructure:"except,omitempty" msgpack:"except,omitempty"`
Flags *BroadcastFlags `json:"flags,omitempty" mapstructure:"flags,omitempty" msgpack:"flags,omitempty"`
}
BroadcastOptions struct {
Rooms *types.Set[Room] `json:"rooms,omitempty" mapstructure:"rooms,omitempty" msgpack:"rooms,omitempty"`
Except *types.Set[Room] `json:"except,omitempty" mapstructure:"except,omitempty" msgpack:"except,omitempty"`
Flags *BroadcastFlags `json:"flags,omitempty" mapstructure:"flags,omitempty" msgpack:"flags,omitempty"`
}

type SessionToPersist struct {
Sid SocketId `json:"sid" mapstructure:"sid" msgpack:"sid"`
Pid PrivateSessionId `json:"pid" mapstructure:"pid" msgpack:"pid"`
Rooms *types.Set[Room] `json:"rooms,omitempty" mapstructure:"rooms,omitempty" msgpack:"rooms,omitempty"`
Data any `json:"data" mapstructure:"data" msgpack:"data"`
}
SessionToPersist struct {
Sid SocketId `json:"sid" mapstructure:"sid" msgpack:"sid"`
Pid PrivateSessionId `json:"pid" mapstructure:"pid" msgpack:"pid"`
Rooms *types.Set[Room] `json:"rooms,omitempty" mapstructure:"rooms,omitempty" msgpack:"rooms,omitempty"`
Data any `json:"data" mapstructure:"data" msgpack:"data"`
}

type Session struct {
*SessionToPersist
Session struct {
*SessionToPersist

MissedPackets []any `json:"missedPackets" mapstructure:"missedPackets" msgpack:"missedPackets"`
}
MissedPackets []any `json:"missedPackets" mapstructure:"missedPackets" msgpack:"missedPackets"`
}

type PersistedPacket struct {
Id string `json:"id" mapstructure:"id" msgpack:"id"`
EmittedAt int64 `json:"emittedAt" mapstructure:"emittedAt" msgpack:"emittedAt"`
Data any `json:"data" mapstructure:"data" msgpack:"data"`
Opts *BroadcastOptions `json:"opts,omitempty" mapstructure:"opts,omitempty" msgpack:"opts,omitempty"`
}
PersistedPacket struct {
Id string `json:"id" mapstructure:"id" msgpack:"id"`
EmittedAt int64 `json:"emittedAt" mapstructure:"emittedAt" msgpack:"emittedAt"`
Data any `json:"data" mapstructure:"data" msgpack:"data"`
Opts *BroadcastOptions `json:"opts,omitempty" mapstructure:"opts,omitempty" msgpack:"opts,omitempty"`
}

type SessionWithTimestamp struct {
*SessionToPersist
SessionWithTimestamp struct {
*SessionToPersist

DisconnectedAt int64 `json:"disconnectedAt" mapstructure:"disconnectedAt" msgpack:"disconnectedAt"`
}
DisconnectedAt int64 `json:"disconnectedAt" mapstructure:"disconnectedAt" msgpack:"disconnectedAt"`
}
)
30 changes: 16 additions & 14 deletions socket/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@ package socket
import (
"sync/atomic"

"github.com/zishang520/engine.io/events"
"github.com/zishang520/engine.io/types"
"github.com/zishang520/engine.io/utils"
"github.com/zishang520/socket.io-go-parser/parser"
"github.com/zishang520/engine.io/v2/events"
"github.com/zishang520/engine.io/v2/types"
"github.com/zishang520/engine.io/v2/utils"
"github.com/zishang520/socket.io-go-parser/v2/parser"
)

type AdapterBuilder struct {
}
type (
AdapterBuilder struct {
}

type adapter struct {
events.EventEmitter
adapter struct {
events.EventEmitter

nsp NamespaceInterface
rooms *types.Map[Room, *types.Set[SocketId]]
sids *types.Map[SocketId, *types.Set[Room]]
encoder parser.Encoder
nsp NamespaceInterface
rooms *types.Map[Room, *types.Set[SocketId]]
sids *types.Map[SocketId, *types.Set[Room]]
encoder parser.Encoder

_broadcast func(*parser.Packet, *BroadcastOptions)
}
_broadcast func(*parser.Packet, *BroadcastOptions)
}
)

func (*AdapterBuilder) New(nsp NamespaceInterface) Adapter {
a := &adapter{}
Expand Down
8 changes: 4 additions & 4 deletions socket/broadcast-operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"sync/atomic"
"time"

"github.com/zishang520/engine.io/types"
"github.com/zishang520/engine.io/utils"
"github.com/zishang520/socket.io-go-parser/parser"
"github.com/zishang520/engine.io/v2/types"
"github.com/zishang520/engine.io/v2/utils"
"github.com/zishang520/socket.io-go-parser/v2/parser"
)

type BroadcastOperator struct {
Expand Down Expand Up @@ -191,7 +191,7 @@ func (b *BroadcastOperator) Emit(ev string, args ...any) error {
timeout = *time
}

timer := utils.SetTimeOut(func() {
timer := utils.SetTimeout(func() {
atomic.StoreUint32(&timedOut, 1)
if b.flags.ExpectSingleResponse {
ack(nil, errors.New("operation has timed out"))
Expand Down
12 changes: 6 additions & 6 deletions socket/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"sync"

_types "github.com/zishang520/engine.io-go-parser/types"
"github.com/zishang520/engine.io/engine"
"github.com/zishang520/engine.io/log"
"github.com/zishang520/engine.io/types"
"github.com/zishang520/engine.io/utils"
"github.com/zishang520/socket.io-go-parser/parser"
"github.com/zishang520/engine.io/v2/engine"
"github.com/zishang520/engine.io/v2/log"
"github.com/zishang520/engine.io/v2/types"
"github.com/zishang520/engine.io/v2/utils"
"github.com/zishang520/socket.io-go-parser/v2/parser"
)

var client_log = log.NewLog("socket.io:client")
Expand Down Expand Up @@ -59,7 +59,7 @@ func (c *Client) setup() {
c.mu_connectTimeout.Lock()
defer c.mu_connectTimeout.Unlock()

c.connectTimeout = utils.SetTimeOut(func() {
c.connectTimeout = utils.SetTimeout(func() {
if c.nsps.Len() == 0 {
client_log.Debug("no namespace joined yet, close the client")
c.close()
Expand Down
10 changes: 6 additions & 4 deletions socket/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import (
"time"

"github.com/mitchellh/mapstructure"
"github.com/zishang520/engine.io/log"
"github.com/zishang520/engine.io/types"
"github.com/zishang520/engine.io/v2/log"
"github.com/zishang520/engine.io/v2/types"
)

var namespace_log = log.NewLog("socket.io:namespace")
var (
namespace_log = log.NewLog("socket.io:namespace")

var NAMESPACE_RESERVED_EVENTS = types.NewSet("connect", "connection", "new_namespace")
NAMESPACE_RESERVED_EVENTS = types.NewSet("connect", "connection", "new_namespace")
)

type Namespace struct {
// _ids has to be first in the struct to guarantee alignment for atomic
Expand Down
12 changes: 7 additions & 5 deletions socket/parent-namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import (
"strconv"
"sync/atomic"

"github.com/zishang520/engine.io/log"
"github.com/zishang520/engine.io/types"
"github.com/zishang520/socket.io-go-parser/parser"
"github.com/zishang520/engine.io/v2/log"
"github.com/zishang520/engine.io/v2/types"
"github.com/zishang520/socket.io-go-parser/v2/parser"
)

var parent_namespace_log = log.NewLog("socket.io:parent-namespace")
var (
parent_namespace_log = log.NewLog("socket.io:parent-namespace")

var count uint64 = 0
count uint64 = 0
)

type ParentNamespace struct {
*Namespace
Expand Down
Loading

0 comments on commit 696aba0

Please sign in to comment.