All wodCrypt (12) wodSSH (10) wodSFTP (23) wodSSHServer (1) wodSSHTunnel (11) wodSSHpackage wodSFTPdll wodSSH.NET (10) wodSFTP.NET (24) wodFtpDLX.NET (22) wodWebServer.NET (10) wodAppUpdate (13) wodHttpDLX (8) wodFtpDLX (22) wodTelnetDLX wodFTPServer (3) wodWebServer (10) wodVPN wodXMPP (13) | All ** [Visual Basic] ** [C#] ** [VB.NET] ** Change user status - XMPP/Jabber
VB code
Dim WithEvents wodXMPP1 As wodXMPPCom Private Sub Form_Load() Set wodXMPP1 = New wodXMPPCom 'In this example we will use ComboBox for changing user status message. 'First we will add description of user status text in ComboBox. Combo1.AddItem "Online" Combo1.AddItem "Free for chat" Combo1.AddItem "Away" Combo1.AddItem "Extended away" Combo1.AddItem "Do not disturb" Combo1.AddItem "Invisible" Combo1.AddItem "Offline" wodXMPP1.Login = "JID__username@domain.com" wodXMPP1.Password = "JID__password" 'Connect to Jabber/XMPP server. wodXMPP1.Connect End Sub 'Connected Event fires when wodXMPP connects to remote server. Private Sub wodXMPP1_Connected() 'When Connected Event is fired, we can then remove contact from our contact list. 'In this example we will do that using button on our form (check Command1_Click). MsgBox "Connected" End Sub 'Disconnected Event fires when wodXMPP disconnects from server. Private Sub wodXMPP1_Disconnected(ByVal ErrorCode As Long, ByVal ErrorText As String) 'Inside Disconnected Event we can check for an error using ErrorText and ErrorCode variable. If ErrorCode <> 0 Then MsgBox "Error: " & ErrorText End If End Sub 'Inside ComboBox Click Event (Combo1_Click) we will change user status using SetStatus Method. Private Sub Combo1_Click() Select Case Combo1.ListIndex Case 0 ' Online wodXMPP1.SetStatus Online Case 1 ' Free for chat wodXMPP1.SetStatus Chat Case 2 ' Away wodXMPP1.SetStatus Away Case 3 ' Extended away wodXMPP1.SetStatus ExtendedAway Case 4 ' Do not disturb wodXMPP1.SetStatus DoNotDisturb Case 5 ' Invisible wodXMPP1.SetStatus Invisible Case 6 ' Offline wodXMPP1.Disconnect End Select 'Display current user status. Debug.Print wodXMPP1.StatusText End Sub VB.NET code
Dim WithEvents wodXMPP1 As WODXMPPCOMLib.wodXMPPCom Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load wodXMPP1 = New WODXMPPCOMLib.wodXMPPCom 'In this example we will use ComboBox for changing user status message. 'First we will add description of user status text in ComboBox. ComboBox1.Items.Add("Online") ComboBox1.Items.Add("Free for chat") ComboBox1.Items.Add("Away") ComboBox1.Items.Add("Extended away") ComboBox1.Items.Add("Do not disturb") ComboBox1.Items.Add("Invisible") ComboBox1.Items.Add("Offline") wodXMPP1.Login = "JID__username@domain.com" wodXMPP1.Password = "JID__password" 'Connect to Jabber/XMPP server. wodXMPP1.Connect() End Sub 'Connected Event fires when wodXMPP connects to remote server. Private Sub wodXMPP1_Connected() Handles wodXMPP1.Connected 'When Connected Event is fired, we can then remove contact from our contact list. 'In this example we will do that using button on our form (check Command1_Click). MsgBox("Connected") End Sub 'Disconnected Event fires when wodXMPP disconnects from server. Private Sub wodXMPP1_Disconnected(ByVal ErrorCode As Integer, ByVal ErrorText As String) Handles wodXMPP1.Disconnected 'Inside Disconnected Event we can check for an error using ErrorText and ErrorCode variable. If ErrorCode <> 0 Then MsgBox("Error: " & ErrorText) End If End Sub 'Inside ComboBox SelectedIndexChanged Event (ComboBox1_SelectedIndexChanged) we will change user status using SetStatus Method. Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Select Case ComboBox1.SelectedIndex Case 0 ' Online wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Online) Case 1 ' Free for chat wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Chat) Case 2 ' Away wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Away) Case 3 ' Extended away wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.ExtendedAway) Case 4 ' Do not disturb wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.DoNotDisturb) Case 5 ' Invisible wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Invisible) Case 6 ' Offline wodXMPP1.Disconnect() End Select 'Display current user status. Console.WriteLine(wodXMPP1.StatusText) End Sub C# code
WODXMPPCOMLib.wodXMPPCom wodXMPP1; private void Form1_Load(object sender, EventArgs e) { wodXMPP1 = new WODXMPPCOMLib.wodXMPPCom(); wodXMPP1.Connected += new WODXMPPCOMLib._IwodXMPPComEvents_ConnectedEventHandler(wodXMPP1_Connected); wodXMPP1.Disconnected += new WODXMPPCOMLib._IwodXMPPComEvents_DisconnectedEventHandler(wodXMPP1_Disconnected); //In this example we will use ComboBox for changing user status message. //First we will add description of user status text in ComboBox. comboBox1.Items.Add("Online"); comboBox1.Items.Add("Free for chat"); comboBox1.Items.Add("Away"); comboBox1.Items.Add("Extended away"); comboBox1.Items.Add("Do not disturb"); comboBox1.Items.Add("Invisible"); comboBox1.Items.Add("Offline"); wodXMPP1.Login = "JID__username@domain.com"; wodXMPP1.Password = "JID__password"; //Connect to Jabber/XMPP server. wodXMPP1.Connect(null); } //Connected Event fires when wodXMPP connects to remote server. private void wodXMPP1_Connected() { //When Connected Event is fired, we can then remove contact from our contact list. //In this example we will do that using button on our form (check Command1_Click). MessageBox.Show("Connected"); } //Disconnected Event fires when wodXMPP disconnects from server. private void wodXMPP1_Disconnected(int ErrorCode, string ErrorText) { //Inside Disconnected Event we can check for an error using ErrorText and ErrorCode variable. if (ErrorCode != 0) { MessageBox.Show("Error: " + ErrorText); } } //Inside ComboBox SelectedIndexChanged Event (ComboBox1_SelectedIndexChanged) we will change user status using SetStatus Method. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { switch (comboBox1.SelectedIndex) { case 0: // Online wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Online, null); break; case 1: // Free for chat wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Chat, null); break; case 2: // Away wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Away, null); break; case 3: // Extended away wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.ExtendedAway, null); break; case 4: // Do not disturb wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.DoNotDisturb, null); break; case 5: // Invisible wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Invisible, null); break; case 6: // Offline wodXMPP1.Disconnect(); break; } //Display current user status. Console.WriteLine(wodXMPP1.get_StatusText(wodXMPP1.Status)); } |