Exemplo n.º 1
0
func (this *RouteServer) execute(conn net.Conn, id int, version byte, serverType byte, dataType byte, dataLen int, data []byte, raw []byte) {
	js := json.NewJSON(data)

	commander.ExecuteCmd1(js, func(result json.JSONObject) {
		log.I_NET("callback from commander, data :", result.ToString())
		put := []byte(result.ToString())
		r, d := protocol.NewProtocol(id, version, serverType, dataType, len(put), put)
		if r {
			conn.Write(d)
		}
	})
}
Exemplo n.º 2
0
func (this *MinorConfig) write2Major(data []byte) {
	ret, p := protocol.NewProtocol(this.config.clientID,
		this.config.version,
		protocol.PROTOCOL_MAJOR_SERVER_TYPE,
		protocol.PROTOCOL_NORMAL_JSON_DATA_TYPE,
		len(data),
		data)
	if ret {
		this.client.Write(p)
	} else {
		log.E_NET("minor id", this.config.clientID, "write to major error, id:", this.config.clientID, ",version:", this.config.version,
			",server type:", protocol.PROTOCOL_MAJOR_SERVER_TYPE, ",data type:", protocol.PROTOCOL_NORMAL_JSON_DATA_TYPE, ",data len:", len(data),
			",data:", data)
	}
}