public Friend sendFriendRequest(Friend friend) { ClientApp._user.addPendingFriend(friend); UpdateTextBoxesDelegate updateDelegate = new UpdateTextBoxesDelegate(ClientApp._form.refreshMyPendingFriends); ClientApp._form.BeginInvoke(updateDelegate); return null; }
public Friend acceptFriendRequest(Friend friend) { RemoteAsyncPostDelegate postDel; AsyncCallback postCallback; ClientApp._user.addFriend(friend); try { if (ClientApp._user.getPendingFriend(friend.Name) != null) ClientApp._user.removePendingFriend(friend.Name); } catch (Exception) { } UpdateTextBoxesDelegate updateDelegate = new UpdateTextBoxesDelegate(ClientApp._form.refreshMyFriends); updateDelegate += ClientApp._form.refreshMyPendingFriends; ClientApp._form.BeginInvoke(updateDelegate); postCallback = new AsyncCallback(ClientApp._form.remoteAsyncSendPostCallBack); postDel = new RemoteAsyncPostDelegate(ClientApp._form.Server.sendPost); postDel.BeginInvoke(new Post(postMessage(ClientApp._user.Username,friend.Name),ClientApp._user.Username),postCallback,null); return null; }
public void RemoteAsyncSendPostCallBack(IAsyncResult ar) { try { RemoteAsyncPostDelegate del = (RemoteAsyncPostDelegate)((AsyncResult)ar).AsyncDelegate; Post newPost = del.EndInvoke(ar); ClientApp._user.addPost(newPost); UpdateTextBoxesDelegate updateDelegate = new UpdateTextBoxesDelegate(refreshMyMural); ClientApp._form.BeginInvoke(updateDelegate); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); } return; }
public void refreshFriends() { //MessageBox.Show(ClientApp._user.Username + " : Vou mandar o form refrescar os meus amigos"); UpdateTextBoxesDelegate updateDelegate = new UpdateTextBoxesDelegate(ClientApp._form.refreshMyFriends); ClientApp._form.BeginInvoke(updateDelegate); }
public void RemoteAsyncRemovePendingFriendCallBack(IAsyncResult ar) { try { RemoteAsyncFriendDelegate del = (RemoteAsyncFriendDelegate)((AsyncResult)ar).AsyncDelegate; Friend friend = del.EndInvoke(ar); if (friend == null) { System.Windows.Forms.MessageBox.Show(Messages.ServiceNotAvailable); return; } ClientApp._user.removePendingFriend(friend.Name); UpdateTextBoxesDelegate updateDelegate = new UpdateTextBoxesDelegate(refreshMyPendingFriends); ClientApp._form.BeginInvoke(updateDelegate); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message + "aqui"); } return; }