public void SetResponse(string command, object data) { ResponseMap[command] = JsonConvert.SerializeObject(data); if (ExtensionMap.ContainsKey(command)) { ExtensionMap[command](); } if (PromiseMap.ContainsKey(command)) { Promise.Promise promise = PromiseMap[command]; PromiseMap.Remove(command); promise.Resolve(); } Signals.ResponseHelper.Dispatch(command); //dispatcher.Dispatch(commandType, command); }
public IPromise Request(string command, string data) { var splitList = command.Split('_'); string newCommand, type = string.Empty; if (splitList.Length > 1) { type = splitList[0]; newCommand = splitList[1]; } else { newCommand = command; } newCommand = command; Debug.Log("Service.Request |> command: " + newCommand + " | type: " + type + " | data: " + data); Promise.Promise promise = new Promise.Promise(); if (PromiseMap.ContainsKey(newCommand)) { PromiseMap[newCommand] = promise; } else { PromiseMap.Add(newCommand, promise); } if (string.IsNullOrEmpty(type)) { if (_processorMap.ContainsKey(newCommand)) { _processorMap[newCommand].Process(newCommand, data); } } else { _processorMap[type].Process(newCommand, data); } return(promise); }