Empower your application with a leading Instant Messenger .NET Software Development Kit
IMSDK.IMServer API
IMSDK API
Forums
Home
/ Support
Support Center
»
Knowledgebase
»
How to Send a message to a Online/Offline Friend
How to Send a message to a Online/Offline Friend
Solution
1. Complete Login User
2. Now Call the Asynchronous Method IMSDK.IMClient.BeginSendMessage
[Visual Basic]
Private Sub send_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles send_btn.Click
oForm1.iMC.BeginSendMessage(Me.Tag, sender_rtb.Text.ToString)
reciver_rtb.Text = reciver_rtb.Text & oForm1.IMCUser.Username & " Says : " & sender_rtb.Text.ToString & vbCrLf
End Sub
3. This Method will send message to friend wether Online or Offline , if the friend is offline this message will be queued as a offline message and event IMSDK.IMClient.OnOfflineMessageQueued will be fired
[Visual Basic]
Private Sub IMC_OnOfflineMessageQueued(ByVal FriendUsername As String, ByVal Message As String) Handles IMC.OnOfflineMessageQueued
Debug.WriteLine("Offline Message :" & vbCrLf & Message & vbCrLf & " is Queued for friend :" & vbCrLf & FriendUsername)
End Sub
4. When a Message is successfully delivered to the friend the event IMSDK.IMClient.OnMessageDelivered is fired
[Visual Basic]
Private Sub IMC_OnMessageDelivered(ByVal Friendusername As String, ByVal Message As String, ByVal DeliveredDate As Date) Handles IMC.OnMessageDelivered
Debug.WriteLine("Message : " & vbCrLf & Message & vbCrLf & "Dilivered to " & Friendusername & vbCrLf & "On Date : " & DeliveredDate, True)
End Sub
5. If the Message Could not be sent then event IMSDK.IMClient.OnMessageNotSent is fired
[Visual Basic]
Private Sub IMC_OnMessageNotSent(ByVal Friendusername As String, ByVal Message As String) Handles IMC.OnMessageNotSent
Debug.WriteLine("Message Not Sent " & vbCrLf & Message & vbCrLf & " Friendusername :" & Friendusername)
End Sub
6. Friend is notified of the incoming message by the event IMSDK.IMClient.OnMessageReceived
[Visual Basic]
Private Delegate Function DlgOnMessageReceived(ByVal From As String, ByVal Message As String) As Boolean
Private Sub IMC_OnMessageReceived(ByVal From As String, ByVal Message As String) Handles IMC.OnMessageReceived
Dim OnMessageReceivedDlg As New DlgOnMessageReceived(AddressOf openchat)
Me.BeginInvoke(OnMessageReceivedDlg, New Object() {From, Message})
End Sub
Function openchat(ByVal username As String, ByVal msg As String) As Boolean
Debug.WriteLine("Username : " & username & " Sent you a message : " & msg)
End Function
Article Details
Article ID:
16
Created On:
14 Apr 2007 01:30 AM
This answer was helpful
This answer was not helpful
User Comments
Add a Comment
Sharing is good. So if you have a comment about this entry please feel free to share. The Comments might be reviewed by our Staff and might require approval before being posted. Questions posted will not be answered, please submit a ticket for support requests.
Fullname:
Email: (Optional)
Comments:
Login
[Lost Password]
Email:
Password:
Remember Me:
Search
-- Entire Support Site --
Knowledgebase
Downloads
Article Options
Add Comment
Print Article
PDF Version
Email Article
Add to Favorites
Home
|
Register
|
Submit a Ticket
|
Knowledgebase
|
Downloads
Language:
English (U.S.)