We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client how do reconnect?
package main import ( "context" "fmt" "github.com/kataras/iris/v12/websocket" "github.com/kataras/neffos" "log" "time" ) const ( endpoint = "ws://192.168.2.45:7000/join" namespace = "default" dialAndConnectTimeout = 6 * time.Second ) var clientEvents = websocket.Namespaces{ namespace: websocket.Events{ websocket.OnNamespaceConnected: func(c *websocket.NSConn, msg websocket.Message) error { log.Printf("connected to namespace: %s", msg.Namespace) room, err := c.JoinRoom(context.TODO(), "default") fmt.Println(err) fmt.Println(room.String()) return nil }, websocket.OnNamespaceDisconnect: func(c *websocket.NSConn, msg websocket.Message) error { log.Printf("disconnected from namespace: %s", msg.Namespace) fmt.Println("reconnect") time.Sleep(time.Second * 1) fmt.Println(c.Conn) return nil }, websocket.OnAnyEvent: func(conn *neffos.NSConn, message neffos.Message) error { fmt.Println(message) return nil }, websocket.OnNativeMessage: func(conn *neffos.NSConn, message neffos.Message) error { fmt.Println(message) return nil }, "chat": func(c *websocket.NSConn, msg websocket.Message) error { log.Printf("%s", string(msg.Body)) return nil }, }, } // 启动 // 检查py引擎是否启动并且上报状态 // 停止 // 保持链接 // 是否运行脚本(当前运行脚本) // 查看日志 // 更新py 工程 func main() { //cmd := exec.Command("whoami") //cmd.Stdout = os.Stdout //cmd.Stderr = os.Stderr //cmd.Run() ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(dialAndConnectTimeout)) defer cancel() dialer := websocket.DefaultGobwasDialer client, err := websocket.Dial(ctx, dialer, endpoint, clientEvents) if err != nil { panic(err) } defer client.Close() client.Connect(ctx, namespace) fmt.Println("wait conn") for { time.Sleep(time.Second * 1) } }
The text was updated successfully, but these errors were encountered:
kataras
No branches or pull requests
client how do reconnect?
The text was updated successfully, but these errors were encountered: