public static void Login(HerokuFacebookLoginAppLoginExperienceAction yield) { Console.WriteLine("loading... "); Native.Window.onmessage += e => { if (yield == null) return; // http://developer.klout.com/blog/read/fb_identity_lookup // onmessage: <response name="Arvo Sulakatko" id="1527339800" third_party_id="PlMBKhbgKYAXmxiXIWoVpH8ULrM"/> try { var xml = XElement.Parse((string)e.data); if (xml.Name.LocalName == "response") { var name = xml.Attribute("name").Value; var id = xml.Attribute("id").Value; var third_party_id = xml.Attribute("third_party_id").Value; yield(id, name, third_party_id); yield = null; } } catch { } }; //var i = new IWindow { }; //i.document.location.href = "http://young-beach-4377.herokuapp.com/"; var i = Native.Window.open("http://young-beach-4377.herokuapp.com/#c", "_blank", 400, 225); // doesnt tell us when loaded? i.onload += delegate { Console.WriteLine("InitializeOurFacebookLoginServiceViaWindowAndClose loading... done..."); //Console.WriteLine("loading... done " + new { i.document.title }); //Console.WriteLine("loading... done " + new { i.document.location.href }); // can we now talk to it? // }; }
public static void Invoke(HerokuFacebookLoginAppLoginExperienceAction yield) { InternalInvoke( data => { if (yield == null) return; //content.t.Text = data; //content.r.Fill = Brushes.Green; try { var xml = XElement.Parse(data); if (xml.Name.LocalName == "response") { Diagnostics("Invoke ack for " + new { data }); #region tx tx.status += delegate { }; tx.allowDomain("*"); tx.allowInsecureDomain("*"); tx.send("_Invoke" + ii + "_ack", "Invoke", "ack!" + ii); #endregion var name = xml.Attribute("name").Value; var id = xml.Attribute("id").Value; var third_party_id = xml.Attribute("third_party_id").Value; var accessToken = xml.Attribute("accessToken").Value; Diagnostics("Invoke yield"); yield(id, name, third_party_id, accessToken); yield = null; } } catch { } } ); }
public static void Invoke(HerokuFacebookLoginAppLoginExperienceAction yield) { InternalInvoke( data => { if (yield == null) { return; } //content.t.Text = data; //content.r.Fill = Brushes.Green; try { var xml = XElement.Parse(data); if (xml.Name.LocalName == "response") { Diagnostics("Invoke ack for " + new { data }); #region tx tx.status += delegate { }; tx.allowDomain("*"); tx.allowInsecureDomain("*"); tx.send("_Invoke" + ii + "_ack", "Invoke", "ack!" + ii); #endregion var name = xml.Attribute("name").Value; var id = xml.Attribute("id").Value; var third_party_id = xml.Attribute("third_party_id").Value; var accessToken = xml.Attribute("accessToken").Value; Diagnostics("Invoke yield"); yield(id, name, third_party_id, accessToken); yield = null; } } catch { } } ); }
public static void Login(HerokuFacebookLoginAppLoginExperienceAction yield) { Initialize( delegate { // initialized? // cached? if (__Login == null) { //yield("id", "name", "1"); return; } __Login(yield); } ); }
public static void Initialize(Action init_done) { if (InitializeDone) { init_done(); return; } InitializeDone = true; Diagnostics("Initialize..."); // does __Login exist? // add a callback ExternalInterface.call("setTimeout", "window.__check__Login = function (e) { return '__Login' in window; };", 0); Diagnostics("prepared __check__Login..."); 100.AtDelay( delegate { Diagnostics("call __check__Login..."); var value = (bool)ExternalInterface.call("__check__Login"); if (value) { // js app is ready for us! var y = default(HerokuFacebookLoginAppLoginExperienceAction); HerokuFacebookLoginAppLoginExperienceAction yield_to_sprite = (string id, string name, string third_party_id) => { if (y == null) { return; } y(id, name, third_party_id); y = null; }; ExternalExtensions.TryAddCallback("__Login_yield", yield_to_sprite.ToFunction()); __Login = yield => { y = yield; Diagnostics("context switch to js"); var value_Login = ExternalInterface.call("__Login"); }; init_done(); } else { Diagnostics("js app needs init"); } } ); }