vb.net VOIP ( voice over ip )
skype (voice over ip)
walkthrough for using skype with vb.net
notes : install skype (voip software), when running skype is running, you signed in it
1 dl skype4com from http://developer.skype.com/accessories
2 extract the zip file (3 files : chm, dll,msm)
3 open vb.net, file, new, project, window application
4 from tool box add :
textbox name : txtCallee
3 radio buttons : radTel, ralCell, radSkype
textbox multiline = true
button btnCall
textbox name: txtMsg
button btnSend
timer name : ChatTimer, true, interval 1000
5 project, add reference, browse , skype4com.dll
6 source code :
global vars : (add below class (after right click form, view code))
Dim oSkype As SKYPE4COMLib.Skype = New SKYPE4COMLib.Skype
Dim oCall As SKYPE4COMLib.Call
Dim oChat As SKYPE4COMLib.Chat
Code:
Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If oSkype.Client.IsRunning = False Then
MsgBox("Skype must be running!")
End
End If
Try
If oSkype.CurrentUserStatus = SKYPE4COMLib.TUserStatus.cusOffline Then
MsgBox("Your Skype account must be online!")
End
End If
Catch ex As Exception
MsgBox("Your Skype account must be online!")
End Try
End Sub
Public Function parseTelNum(ByVal input As String, ByVal defaultIntl As String, ByVal defaultArea As String)
Dim result As String
result = input.Replace("-", " ")
If result.StartsWith("0") Then
Return "+" & defaultIntl & result.Substring(1)
ElseIf result.StartsWith("+") Then
Return result
Else
Return "+" & defaultIntl & defaultArea & result
End If
End Function
Private Sub btnCall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCall.Click
If btnCall.Text = "Call" Then
If txtCallee.Text = " " Then
Exit Sub
End If
If radTel.Checked = True Then
Try
oCall = oSkype.PlaceCall(parseTelNum(txtCallee.Text, "972", "2"))
btnCall.Text = "Hang up"
Catch ex As Exception
MsgBox("Couldn't place the call." & vbCrLf & "Please make sure the input you entered is valid!")
End Try
ElseIf radCell.Checked = True Then
oCall = oSkype.PlaceCall(parseTelNum(txtCallee.Text, "972", "52"))
Else
oCall = oSkype.PlaceCall(txtCallee.Text)
Else
oCall.Finish()
btnCall.Text = "Call"
End If
End Sub
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
If txtCallee.Text = " " Or txtMsg.Text = " " Then
Exit Sub
End If
If radTel.Checked = True Then
Try
oSkype.SendSms(parseTelNum(txtCallee.Text, "972", "2"), txtMsg.Text)
txtMsg.Text = ""
Catch ex As Exception
MsgBox("Coudn't send the SMS." & vbCrLf & "Please make sure the input you entered is valid!")
End Try
ElseIf radCell.Checked = True Then
oSkype.SendSms(parseTelNum(txtCallee.Text, "972", "52"), txtMsg.Text)
Else
oSkype.SendMessage(txtCallee.Text, txtMsg.Text)
MsgBox("Couldn't sent the message." & vbCrLf & "Please make sure the input you entered is valid!")
End Sub
Private Sub ChatTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChatTimer.Tick
txtChat.Text = ""
If txtCallee.Text <> "" Then
oChat = oSkype.CreateChatWith(txtCallee.Text)
Try
Dim temp = oChat.Messages
Catch ex As Exception
txtChat.Text = "No such username or no chat available." & vbCrLf & ex.ToString
Exit Sub
End Try
For Each oMsg As SKYPE4COMLib.ChatMessage In oChat.Messages
If Not oMsg.Body.ToString.StartsWith("<pa") And oMsg.Body.ToString <> "" Then
txtChat.Text = txtChat.Text & vbCrLf & oMsg.Sender.FullName & ": " & oMsg.Body
End If
Next
oSkype.ResetCache()
End If
End Sub
you can test on the skype bot "echo123"
please don't spam
Re: vb.net VOIP ( voice over ip )
Cool! I might see how I go with doing this in C#.
Re: vb.net VOIP ( voice over ip )
Re: vb.net VOIP ( voice over ip )
Quote:
Originally Posted by
moti barski
no rate :( ?
Check your visitor messages.
Re: vb.net VOIP ( voice over ip )