/*ServerStream FbFeedStreamWaiting = null; * static void feed(ServerStream svstream) { * if (FacebookClient.Instance.Token.Length > 0 && FbFeedStreamWaiting == null) { * StreamBuffer buf = new StreamBuffer(svstream.PostData); * string message = buf.readSStr(); * FbFeedStreamWaiting = svstream; * FacebookClient.Instance.PostMessageOnWall(AppObject.GameInfo.FacebookFeedTitle, * message, * //AppObject.GameInfo.FacebookFeedAttahLink, * AppObject.AppLink, * AppObject.GameInfo.FacebookFeedImageUrl, * new UploadStringCompletedEventHandler(fb_feed_handle)); * } else { * svstream.Status = (int)ServerStreamStatus.STREAM_STATUS_ERROR; * } * } * static private void fb_feed_handle(object sender, UploadStringCompletedEventArgs e) { * if (FbFeedStreamWaiting != null) { * if (e != null && e.Error == null) { * FbFeedStreamWaiting.Status = (int)ServerStreamStatus.STREAM_STATUS_RESPONSED; * //MessageBox.Show("Completed"); * } else { * FbFeedStreamWaiting.Status = (int)ServerStreamStatus.STREAM_STATUS_ERROR; * //MessageBox.Show("Error! Please retry later"); * } * FbFeedStreamWaiting = null; * } * } * */ static public void getFriends(Actions.DelegateBegin onBegin, Actions.DelegateDone onDone, Actions.DelegateCancel onCancel) { Actions.ActionFacebookGetFriendsArg arg = new Actions.ActionFacebookGetFriendsArg(); Actions.ActionFacebookGetFriends action_fbfriend = new Actions.ActionFacebookGetFriends(); try { if (onBegin != null) { action_fbfriend.OnBegin += onBegin; } if (onDone != null) { action_fbfriend.OnDone += onDone; } if (onCancel != null) { action_fbfriend.OnCancel += onCancel; } action_fbfriend.Do(arg); } catch (Exception ex) { if (onCancel != null) { onCancel(null, arg); } } }
private void LoadFriendComplete(object sender, DownloadStringCompletedEventArgs e) { try { if (_wating.ContainsKey((WebClient)sender)) { ActionFacebookGetFriendsArg arg = _wating[(WebClient)sender]; arg.FriendIds.Clear(); _wating.Remove((WebClient)sender); if (e != null && !e.Cancelled && e.Error == null) { string result = e.Result; if (result.IndexOf("uid") > 0) { var juser = JsonConvert.DeserializeObject <FriendListVer1>(result); if (juser != null && juser.data.Count > 0) { for (int f = 0; f < juser.data.Count; f++) { arg.FriendIds.Add(Int64.Parse(juser.data[f].uid)); } } } else { var juser = JsonConvert.DeserializeObject <FriendsList>(result); if (juser != null && juser.data.Count > 0) { for (int f = 0; f < juser.data.Count; f++) { arg.FriendIds.Add(Int64.Parse(juser.data[f].id)); } } } //if(juser.paging.next) Done(arg); } else { Cancel(arg); } } else { Debug.WriteLine("abc"); } } catch (Exception ex) { try { ActionFacebookGetFriendsArg arg = _wating[(WebClient)sender]; Cancel(arg); } catch (Exception nex) { } } }