private async void btnLogin_Click(object sender, EventArgs e) { uid = txtUser.Text; string pwd = pswd.Text; if (string.IsNullOrEmpty(uid) || string.IsNullOrEmpty(pwd) || uid.Length != 5 || pwd.Length != 6) { MessageBox.Show("login", "user/password invalid!"); return; } try { AnClient.Init(txtUrl.Text); await AnClient.Login(uid, "----------" + pwd, (code, resp) => { client = new SessionClient(resp.ssInf); txtRegistry.Text = client.ssInf.ssid; }); } catch (Exception x) { MessageBox.Show(x.Message, "Jserv Login Exception"); } }
private void toLogin(object sender, RoutedEventArgs e) { if (LangExt.isblank(jserv.Text.Trim())) { jserv.Text = "127.0.0.1"; } if (LangExt.isblank(port.Text.Trim())) { port.Text = "8080"; } AnClient.Init(string.Format("http://{0}:{1}/{2}", jserv.Text, port.Text, jservPath)); // AlbumContext login(String uid, String pswd, TierCallback onOk, JProtocol.OnError onErr) singleton.login(); }
AlbumContext login(string uid, string pswd) { if (LangExt.isblank(photoUser.device, new string[] { "\\.", "/", "\\?", ":" })) { throw new Exception("Device Id is null."); } AnClient.Init(jserv + "/" + jdocbase, verbose); LoginHandler callback = new LoginHandler(); AnClient.Login(uid, pswd, photoUser.device, callback, callback); /* * (SessionClient client) => * { * client.closeLink(); * * tier = new AlbumClientier(clientUri, client, errCtx); * * client.openLink(clientUri, onHeartbeat, onLinkBroken, 19900); // 4 times failed in 3 min * state = ConnState.Online; * if (onOk != null) * onOk.ok(tier); * }, * // Design Note: since error context don't have unified error message box, * // error context pattern of React is not applicable. * // errCtx.onError(c, r, (Object)v); * (MsgCode c, string r, object v) => { * state = ConnState.LoginFailed; * if (onErr != null) * onErr.err(c, r, v); * }, photoUser.device); */ return(this); }
/* * JProtocol.OnOk onHeartbeat = ((resp) => { * if (state == ConnState.Disconnected) * ; // how to notify? * state = ConnState.Online; * }); * * JProtocol.OnError onLinkBroken = ((c, r, args) => { * state = ConnState.Disconnected; * }); */ public AlbumContext Jserv(string newVal) { jserv = newVal; AnClient.Init(jserv + "/" + jdocbase, verbose); return(this); }