package app

import (
	"fmt"
	"robot/config"
	"robot/internal/ws"
)

// ModuleWebsocket Websocket客户端模块
type ModuleWebsocket struct {
	manager *ws.Manager
}

func (p *ModuleWebsocket) init() error {
	cfg := config.Get().Client
	addr := fmt.Sprintf("%s:%d", cfg.Websocket.Address, cfg.Websocket.Port)
	if cfg.Websocket.Port == 0 {
		addr = cfg.Websocket.Address
	}
	p.manager = ws.NewManager(addr)
	return nil
}

func (p *ModuleWebsocket) start() error {
	p.manager.Start()
	return nil
}

func (p *ModuleWebsocket) stop() error {
	return nil
}
