Comments (7)
@zishang520, Are there any plans to add?
This feature is currently being perfected, and I will release it as soon as it is perfected. I now need to deal with my existing work and life issues first.
from socket.io.
Hello, currently not supported.
from socket.io.
@zishang520, Are there any plans to add?
from socket.io.
@dotX12 I have now completed the development version of the Redis adapter, but have not proceeded with further testing yet. My evaluation may have some issues. Could you help with additional testing?
go mod: https://github.com/zishang520/socket.io-go-redis
demo:
package main
import (
"context"
"os"
"os/signal"
"regexp"
"syscall"
"github.com/redis/go-redis/v9"
_types "github.com/zishang520/engine.io-go-parser/types"
"github.com/zishang520/engine.io/v2/types"
"github.com/zishang520/engine.io/v2/utils"
"github.com/zishang520/socket.io-go-redis/adapter"
rtypes "github.com/zishang520/socket.io-go-redis/types"
"github.com/zishang520/socket.io/v2/socket"
)
func main() {
opts := socket.DefaultServerOptions()
opts.SetAllowEIO3(true)
opts.SetCors(&types.Cors{
Origin: "*",
Credentials: true,
})
redisClient := rtypes.NewRedisClient(context.Background(), redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Username: "",
Password: "",
DB: 0,
}))
redisClient.On("error", func(errors ...any) {
utils.Log().Error("Error: %v", errors)
})
opts.SetAdapter(&adapter.RedisAdapterBuilder{
Redis: redisClient,
Opts: &adapter.RedisAdapterOptions{},
})
httpServer := types.NewWebServer(nil)
socketio := socket.NewServer(httpServer, opts)
socketio.Of(
regexp.MustCompile(`/\w+`),
nil,
).Use(func(client *socket.Socket, next func(*socket.ExtendedError)) {
next(nil)
}).On("connection", func(clients ...interface{}) {
client := clients[0].(*socket.Socket)
client.On("event", func(clients ...interface{}) {
client.Emit("event", map[string]interface{}{
"message": _types.NewStringBufferString("event"),
})
})
})
httpServer.Listen("127.0.0.1:3000", nil)
exit := make(chan struct{})
SignalC := make(chan os.Signal)
signal.Notify(SignalC, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
for s := range SignalC {
switch s {
case syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT:
close(exit)
return
}
}
}()
<-exit
socketio.Close(nil)
os.Exit(0)
}
from socket.io.
I try BroadcastWithAck
function ,get "operation has timed out",
io.To(socket.Room(da["room"].(string))).Timeout(1000*time.Millisecond).Emit("test", da["message"], func(msg []any, err error) {log.Println(msg, err)})
this is my code https://github.com/shitingbao/socket.io_go/blob/main/example/adapter.go
and I tried to implement this process myself and had the same problem,code myself https://github.com/shitingbao/socket.io_go/blob/main/example/redis_adapter_example.go
,I find local function not
implement Ack function in BroadcastWith,this will result in no BroadcastWithAck callback in redis adapter,because MESSAGE_BROADCAST_ACK not callback in redis subscribe
from socket.io.
There are indeed many problems and need to be refactored. Thank you for your help in testing.
from socket.io.
@dotX12 @minbala I added a basic library to implement basic functions. You can try to use it first and improve it yourself, saving some repetitive work.in this https://github.com/shitingbao/socketio-go-redis-adapter
from socket.io.
Related Issues (20)
- Benchmarking HOT 3
- Is *socket.Server Emit() safe for concurrent use? HOT 1
- Start https socket server HOT 1
- 怎么添加这个库为依赖 HOT 5
- How to get the clients or one of them HOT 2
- Does this project have Discord or Telegram group? HOT 1
- Golang client HOT 6
- 如何实现回调功能 HOT 6
- ack 回调中的err参数具体是什么?有没有例子? HOT 8
- Possible to Ack incomming client EmitWithAck messages? HOT 1
- how to use on echo web freamwork HOT 2
- Nothing, absolutely nothing. works. Not even the default samples.
- Do you mind looking into Fiber adaptor for net/http interface to make this library work with fiber applications? HOT 6
- EmitwithAck never listens for the callback from the client so it always timed out HOT 6
- how to fetch /socket.io/socket.io.js ? HOT 4
- 请问socketio的reconnect机制到底啥玩意 HOT 6
- socket.io client question HOT 4
- 使用文档示例代码运行后用客户端无法连接 HOT 2
- How to get the server room HOT 2
- How to create a client on the server? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socket.io.