private void HoloOASIS_OnZomeFunctionCallBack(object sender, ZomeFunctionCallBackEventArgs e) { if (!e.IsCallSuccessful) { HandleError(string.Concat("Zome function ", e.ZomeFunction, " on zome ", e.Zome, " returned an error. Error Details: ", e.ZomeReturnData), null, null); } //OnHoloOASISError?.Invoke(this, new ErrorEventArgs() { EndPoint = HoloNETClient.EndPoint, Reason = string.Concat("Zome function ", e.ZomeFunction, " on zome ", e.Zome, " returned an error. Error Details: ", e.ZomeReturnData) }); else { switch (e.ZomeFunction) { case LOAD_PROFILE_FUNC: HcProfile hcProfile = JsonConvert.DeserializeObject <HcProfile>(string.Concat("{", e.ZomeReturnData, "}")); OnPlayerProfileLoaded?.Invoke(this, new ProfileLoadedEventArgs { HcProfile = hcProfile, Profile = ConvertHcProfileToProfile(hcProfile) }); //TODO: Want to use these eventually so the async methods can return the results without having to use events/callbacks! _taskCompletionSourceLoadProfile.SetResult(ConvertHcProfileToProfile(JsonConvert.DeserializeObject <HcProfile>(string.Concat("{", e.ZomeReturnData, "}")))); break; case SAVE_PROFILE_FUNC: // TODO: Eventually want to return the Profile object from HC with the HCAddressHash set when I work out how! ;-) // The dictonary below can then be removed. //if (string.IsNullOrEmpty(_savingProfiles[e.Id].HcAddressHash)) //{ // //TODO: Forced to re-save the object with the address (wouldn't that create a new hash entry?!) _savingProfiles[e.Id].hc_address_hash = e.ZomeReturnData; _savingProfiles[e.Id].provider_key = e.ZomeReturnData; //Generic field for providers to store their key (in this case the address hash) // SaveProfileAsync(_savingProfiles[e.Id]); //} //else //{ Profile profile = ConvertHcProfileToProfile(_savingProfiles[e.Id]); OnPlayerProfileSaved?.Invoke(this, new ProfileSavedEventArgs { Profile = profile, HcProfile = _savingProfiles[e.Id] }); _taskCompletionSourceSaveProfile.SetResult(profile); _savingProfiles.Remove(e.Id); //} //TODO: Want to use these eventually so the async methods can return the results without having to use events/callbacks! // _taskCompletionSourceIProfile.SetResult(JsonConvert.DeserializeObject<IProfile>(e.ZomeReturnData)); break; } } }
private static void HoloNETClient_OnZomeFunctionCallBack(object sender, ZomeFunctionCallBackEventArgs e) { Console.WriteLine(string.Concat("ZomeFunction CallBack: EndPoint: ", e.EndPoint, ", Id: ", e.Id, ", Instance: ", e.Instance, ", Zome: ", e.Zome, ", ZomeFunction: ", e.ZomeFunction, ", Data: ", e.ZomeReturnData, ", Raw Zome Return Data: ", e.RawZomeReturnData, ", Raw JSON Data: ", e.RawJSONData, ", IsCallSuccessful: ", e.IsCallSuccessful? "true" : "false")); Console.WriteLine(""); }
private static void ZomeCallback(object sender, ZomeFunctionCallBackEventArgs e) { Console.WriteLine(string.Concat("ZomeCallbackDelegate: Id: ", e.Id, ", Instance: ", e.Instance, ", Zome: ", e.Zome, ", ZomeFunction: ", e.ZomeFunction, ", Data: ", e.ZomeReturnData, ", Raw Zome Return Data: ", e.RawZomeReturnData, ", Raw JSON Data: ", e.RawJSONData, ", IsCallSuccessful: ", e.IsCallSuccessful ? "true" : "false")); Console.WriteLine(""); }