예제 #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 *Protocol) Deal1001(client *Client, body map[string]interface{}) {
	id := body["id"]
	pwd := body["pwd"]

	result := model.SharedPlayerModel().Login(int64(id.(float64)), pwd.(string))
	hadSkin := model.SharedPlayerModel().HadSkin(int64(id.(float64)))

	var responseBody tbs.Message = make(tbs.Message)

	var resultCode int
	if result {
		resultCode = 0
	} else {
		resultCode = 1
	}
	responseBody["result"] = resultCode
	responseBody["hadSkin"] = hadSkin

	client.SendPack(1001, responseBody)
}
예제 #3
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)
}