alt/services/api/internal/socket/server.go
toki a8a0f691cf feat: API-centered proto socket rail milestone completion
- Add socket handler and server implementations for real-time communication
- Add Mattermost integration (auth service, push client, plugin client)
- Add Mattermost push host integration tests
- Update Flutter client app with new app structure and bootstrap
- Update Android build configurations and add Google Services config
- Add asset keep file for Flutter client
- Update agent-roadmap with api-centered-proto-socket-rail milestone
- Update agent-task with planning and code review documents for all groups
- Update domain rules for api, client, worker and project rules
2026-05-30 18:34:50 +09:00

29 lines
927 B
Go

package socket
import (
protoSocket "git.toki-labs.com/toki/proto-socket/go"
"nhooyr.io/websocket"
"git.toki-labs.com/toki/alt/services/api/internal/config"
apiContracts "git.toki-labs.com/toki/alt/services/api/internal/contracts"
)
const (
serverName = "alt-api"
serverVersion = "dev"
defaultAltProtocolVersion = "alt.v1"
)
func NewServer(cfg config.Config) *protoSocket.WsServer {
options := protoSocket.WsServerOptions{}
if len(cfg.WSOriginPatterns) > 0 {
options.AcceptOptions = &websocket.AcceptOptions{
OriginPatterns: cfg.WSOriginPatterns,
}
}
server := protoSocket.NewWsServerWithOptions(cfg.Host, cfg.Port, cfg.SocketPath, options, func(conn *websocket.Conn) *protoSocket.WsClient {
return protoSocket.NewWsClient(conn, cfg.HeartbeatIntervalSec, cfg.HeartbeatWaitSec, apiContracts.ParserMap())
})
server.OnClientConnected = registerSessionHandlers
return server
}