void Login() { URLRequestMessage msg = new URLRequestMessage(this); msg.AddMessage(Global.MSG_LOGIN_USERNAME, "areshero"); msg.AddMessage(Global.MSG_LOGIN_PASSWORD, "balala"); VREvents.FireRequestLogin(msg); }
public void RequestLiveVideoList(int number) { URLRequestMessage msg = new URLRequestMessage(this); msg.AddMessage(Global.MSG_REQUESTVIDEO_NUMBER_KEY, number.ToString()); VREvents.FireRequestLiveVideoList(msg); }
void CategoryVideoHandeler(WWW www, URLRequestMessage postMsg) { JSONObject json = new JSONObject(www.text); List <VideoInfo> list = Json2VideoList(json.GetField("videoList")); string name = postMsg.GetMessage(Global.MSG_REQUEST_CATEGORYVIDEO_CATEGORY_KEY).ToString(); postMsg.AddMessage(Global.MSG_POSTVIDEO_VIDEO_KEY, list); VREvents.FirePostVideoList(postMsg); }
override public void OnConfirm() { // Debug.Log("[On Confirm]" + name); base.OnConfirm(); { URLRequestMessage msg = new URLRequestMessage(this); msg.AddMessage(Global.MSG_REQUEST_CATEGORYVIDEO_CATEGORY_KEY, m_info.name); VREvents.FireRequestCategoryVideoList(msg); } }
void LoginHandler(WWW www, URLRequestMessage msg) { JSONObject info = new JSONObject(www.text); string token = info.GetField("token").str; Debug.Log("Get TOKEN" + token); msg.AddMessage(Global.MSG_LOGIN_TOKEN, token); VREvents.FirePostLogin(msg); }
void RequestCategoryVideoList(URLRequestMessage msg) { string url = msg.url; if (string.IsNullOrEmpty(url)) { string category = msg.GetMessage(Global.MSG_REQUEST_CATEGORYVIDEO_CATEGORY_KEY).ToString(); url = Global.CategoryVideoRequestURL.Replace("CATEGORY", category); msg.AddMessage(Global.MSG_POSTVIDEO_NAME_KEY, category); } StartCoroutine(WaitForRequest(url, CategoryVideoHandeler, msg)); }
/// <summary> /// Deal with the request video info /// </summary> /// <param name="msg">Message.</param> void RequestVideoInfo(URLRequestMessage msg) { // Debug.Log(" Request Video Info "); string url = msg.url; if (string.IsNullOrEmpty(url)) { string number = msg.GetMessage(Global.MSG_REQUESTVIDEO_NUMBER_KEY).ToString(); url = Global.VideoRequestURL.Replace("NUMBER", number); } msg.AddMessage(Global.MSG_POSTVIDEO_NAME_KEY, "Latest"); StartCoroutine(WaitForRequest(url, DayVideoInfoHandler, msg)); }
/// <summary> /// extract the texture in the www, /// save in the message with key Global.MSG_REQUEST_TEXTURE_TEXTURE_KEY, /// and post the event 'PostTexture' /// </summary> /// <param name="www">Www.</param> /// <param name="postMsg">Post message.</param> void TextureHandler(WWW www, URLRequestMessage postMsg) { Texture2D tex = www.texture; Rect rec = new Rect(0, 0, tex.width, tex.height); Sprite sprite = Sprite.Create(tex, rec, new Vector2(0.5f, 0.5f), 100); if (!textureCache.ContainsKey(postMsg.url) && HttpHelper.GetDownloadState(postMsg.url) == HttpHelper.DownloadState.Finished) { textureCache.Add(postMsg.url, sprite); } postMsg.AddMessage(Global.MSG_REQUEST_TEXTURE_SPRITE_KEY, sprite); VREvents.FirePostTexture(postMsg); }
/// <summary> /// Deal with the request texture /// </summary> /// <param name="msg">Message.</param> void RequestTexture(URLRequestMessage msg) { string url = msg.url; { Sprite sprite; if (textureCache.TryGetValue(url, out sprite)) { msg.AddMessage(Global.MSG_REQUEST_TEXTURE_SPRITE_KEY, sprite); VREvents.FirePostTexture(msg); return; } } StartCoroutine(WaitForRequestAsy(url, TextureHandler, msg)); }
/// <summary> /// Transfrom the video info from jason(string) to VideoInfo(class), /// save in the message with key Global.MSG_POSTVIDEO_VIDEO_KEY /// and post the 'PostVideoList' event /// </summary> /// <param name="www">Www.</param> /// <param name="postMsg">Post message.</param> void DayVideoInfoHandler(WWW www, URLRequestMessage postMsg) { List <VideoInfo> list = new List <VideoInfo>(); JSONObject json = new JSONObject(www.text); JSONObject dailyList = json.GetField("dailyList"); if (dailyList.IsArray) { foreach (JSONObject day in dailyList.list) { JSONObject videoList = day.GetField("videoList"); list.AddRange(Json2VideoList(videoList)); } } postMsg.AddMessage(Global.MSG_POSTVIDEO_VIDEO_KEY, list); VREvents.FirePostVideoList(postMsg); }
void CategoryHandler(WWW www, URLRequestMessage msg) { List <CategoryInfo> list = new List <CategoryInfo>(); JSONObject categorys = new JSONObject(www.text); if (categorys.IsArray) { foreach (JSONObject category in categorys.list) { CategoryInfo info = new CategoryInfo(); info.name = category.GetField("name").str; info.bgUrl = category.GetField("bgPicture").str; list.Add(info); } } msg.AddMessage(Global.MSG_POSTCATEGORY_CATEGORYLIST_KEY, list); VREvents.FirePostCategory(msg); }