You are here: MessengerYouLike.IMSDK > IMSDK Reference > IMSDK Namespace > Classes > IMClient Class > IMClient Methods > IMClient.BeginFriendBlockUnBlock Method
MessengerYouLike
IMClient.BeginFriendBlockUnBlock Method

This Method Allows Users To Block or Unblock a specific Contact

C#
public BeginFriendBlockUnBlock(String FriendUsername, Boolean Block);
Visual Basic
Public Sub BeginFriendBlockUnBlock(ByVal FriendUsername As String, ByVal Block As Boolean)
Parameters 
Description 
ByVal FriendUsername As String 
username of the Contact Being Blocked 
ByVal Block As Boolean 
True = Block This Contact
False = Unblock This Contact  

This Sub Blocks or Unblocks a Contact based on the Boolean Value of parameter Block.If the Contact is Online it will be Blocked or Unblocked Live and a event will be fired IMSDK.IMClient.OnFriendBlocked if Blocked and if Unblocked then event IMSDK.IMClient.OnFriendUnBlocked will be fired 

 

 

if Contact "A" Blocks Contact "B" then 

1 - Contacts "B" IMSDK.IMClient.Status Will be Set to IMSDK.IMClient.Status.AppearOffline 

2 - In Contact "A" ContactsList Contact "B" Property IMSDK.Friends.MFriend.Blocked will be set to True 

3 - In Contact "B" ContactsList Contact "A" Property IMSDK.Friends.MFriend.AmIBlocked will be set to True 

 

if Contact "A" UnBlocks Contact "B" then 

1 - Contacts "B" IMSDK.IMClient.Status Will be Set to IMSDK.IMClient.Status.Online 

2 - In Contact "A" ContactsList Contact "B" Property IMSDK.Friends.MFriend.Blocked will be set to False 

3 - In Contact "B" ContactsList Contact "A" Property IMSDK.Friends.MFriend.AmIBlocked will be set to False 

 

after the friend is blocked if the IMSDK.IMClient.Status of the friend is changed then the blocked friend status will also be changed to that but the property IMSDK.Friends.MFriend.Blocked will be same 

 

This method Also tells your Contact wether he/she is blocked by you or not as a developer you have a option to hide this from the Logged in user and there contacts

[Visual Basic]
 
'Create a new IMClient
Dim MC as new IMSDK.IMClient
 
 
 
'Call the Listen Sub
MC.Listen()
 
 
 
'Now Try to login
MC.BeginLogin(TxtUsername.Text,TxtPassword.Text)
 
 
 
'if username and password is valid then
Private Sub MC_OnLoggedin(ByVal UserObject As IMSDK.User) Handles MC.OnLoggedin
    Debug.WriteLine("Username logged in : " & MCUser.Username & " , " & MCUser.Password)
End Sub
 
 
 
'if username or password is invalid then
Private Sub MC_OnUsernameOrPasswordInvalid(ByVal Username As String, ByVal Password As String) Handles MC.OnUsernameOrPasswordInvalid
  Debug.WriteLine("Username password invalid : " & Username & " , " & Password)
End Sub
 
 
 
 
'To Block a Contact
MC.BeginFriendBlockUnBlock(TxtFriendusername.text, True)
 
 
'Then Event
 Private Sub MC_OnFriendBlocked(ByVal FriendUsername As String) Handles MC.OnFriendBlocked
   Debug.WriteLine(FriendUsername & " Blocked")
 End Sub
 
 
 
 
 
'To Unblock a Contact
MC.BeginFriendBlockUnBlock(TxtFriendusername.text, False)
 
 
'Then Event
Private Sub MC_OnFriendUnBlocked(ByVal FriendUsername As String) Handles MC.OnFriendUnBlocked
     Debug.WriteLine(FriendUsername & " UnBlocked")
End Sub
Copyright (c) 2007. All rights reserved.