func getJSONFromFileConfig(file string) json.JSONObject { f, err := os.Open(file) if err == nil { data, e := ioutil.ReadAll(f) if e == nil { js := json.NewJSON(data) return js } } return nil }
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) } }) }
func (this *MinorConfig) ReadData(conn net.Conn, data []byte) { ret, id, _, st, dt, _, _, l, d := protocol.ParseProtocol(data, len(data)) if ret { if dt == protocol.PROTOCOL_NORMAL_JSON_DATA_TYPE { j := json.NewJSON(d[:l]) ok, msg_type := j.GetString(MSG_TYPE) okk, identity := j.GetString(IDENTITY) if ok && okk { if msg_type == MSG_TYPE_VALUE_IDENTIFICATION && identity == IDENTITY_VALUE_MICRO_SERVER && st == this.config.microServerType { this.connectedMicroServerNum++ this.connectedMicroServerAddress[id] = conn.RemoteAddr().String() this.write2MajorUpdataMicroServer() } } } } }