Пример #1
0
func (this *GameMain) init() {
	model.SharedPlayerModel()

	http.Handle("/", websocket.Handler(this.acceptHandler))

	this.ClientMap = make(map[int32]*Client)

	this.dispatcher = tbs.SharedDispatcher()
}
Пример #2
0
func (this *Crossdomain) init() {
	this.serverSocket = tbs.CreateServerSocket()
	this.dispatcher = tbs.SharedDispatcher()

	var cb1 tbs.EventCallback = this.onServerStarted
	var cb2 tbs.EventCallback = this.onAccept

	this.dispatcher.AddEventListener(tbs.ServerStarted, &cb1)
	this.dispatcher.AddEventListener(tbs.Accept, &cb2)
}
Пример #3
0
func (this *Client) init() {
	this.protocol = SharedProtocol()

	this.dispatcher = tbs.SharedDispatcher()

	var cb1 tbs.EventCallback = this.onData
	this.cbReceiveData = &cb1
	var cb2 tbs.EventCallback = this.onClosed
	this.cbClosed = &cb2

	this.dispatcher.AddEventListener(tbs.ReceiveData, this.cbReceiveData)
	this.dispatcher.AddEventListener(tbs.Closed, this.cbClosed)
}
Пример #4
0
func (this *GameMain) init() {
	m := md5.New()
	m.Write([]byte("jsj092"))
	println(hex.EncodeToString(m.Sum(nil)))

	model.SharedPlayerModel()

	this.serverSocket = tbs.CreateServerSocket()

	this.ClientMap = make(map[int32]*Client)

	this.dispatcher = tbs.SharedDispatcher()

	var cb1 tbs.EventCallback = this.onServerStarted
	var cb2 tbs.EventCallback = this.onAccept

	this.dispatcher.AddEventListener(tbs.ServerStarted, &cb1)
	this.dispatcher.AddEventListener(tbs.Accept, &cb2)
}