package main

import (
	"time"

	"mongo.games.com/goserver/core"
	_ "mongo.games.com/goserver/core/builtin/action"
	_ "mongo.games.com/goserver/core/builtin/filter"
	"mongo.games.com/goserver/core/module"
	"mongo.games.com/goserver/core/netlib"
)

var (
	Config         = Configuration{}
	PressureModule = &PressureTest{}
	StartCnt       = 0
)

type Configuration struct {
	Count    int
	Connects netlib.SessionConfig
}

func (this *Configuration) Name() string {
	return "pressure"
}

func (this *Configuration) Init() error {
	this.Connects.Init()
	return nil
}

func (this *Configuration) Close() error {
	return nil
}

type PressureTest struct {
}

func (this PressureTest) ModuleName() string {
	return "pressure-module"
}

func (this *PressureTest) Init() {
	cfg := Config.Connects
	for i := 0; i < Config.Count; i++ {
		cfg.Id += i
		netlib.Connect(&cfg)
	}
}

func (this *PressureTest) Update() {
	return
}

func (this *PressureTest) Shutdown() {
	module.UnregisteModule(this)
}

func init() {
	core.RegistePackage(&Config)
	module.RegisteModule(PressureModule, time.Second*30, 50)
}
