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] ** Add custom status message - 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() 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. 'In this example we will add custom status message in Text1.Text. So please add TextBox to your form. Private Sub Combo1_Click() Select Case Combo1.ListIndex Case 0 ' Online wodXMPP1.SetStatus Online, Text1.Text 'Insert custom status message inside Text1.Text Case 1 ' Free for chat wodXMPP1.SetStatus Chat, Text1.Text Case 2 ' Away wodXMPP1.SetStatus Away, Text1.Text Case 3 ' Extended away wodXMPP1.SetStatus ExtendedAway, Text1.Text Case 4 ' Do not disturb wodXMPP1.SetStatus DoNotDisturb, Text1.Text Case 5 ' Invisible wodXMPP1.SetStatus Invisible Case 6 ' Offline wodXMPP1.Disconnect End Select Debug.Print wodXMPP1.StatusText End Sub Private Sub Text1_Change() Combo1_Click 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 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 Click Event (Combo1_Click) we will change user status using SetStatus Method. 'In this example we will add custom status message in TextBox1.Text. So please add TextBox to your form. 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, TextBox1.Text) 'Insert custom status message inside TextBox1.Text Case 1 ' Free for chat wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Chat, TextBox1.Text) Case 2 ' Away wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Away, TextBox1.Text) Case 3 ' Extended away wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.ExtendedAway, TextBox1.Text) Case 4 ' Do not disturb wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.DoNotDisturb, TextBox1.Text) 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 Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged ComboBox1_SelectedIndexChanged(ComboBox1, New System.EventArgs()) 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() { 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 Click Event (Combo1_Click) we will change user status using SetStatus Method. //In this example we will add custom status message in textBox1.Text. So please add TextBox to your form. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { switch (comboBox1.SelectedIndex) { case 0: // Online wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Online, textBox1.Text); //Insert custom status message inside textBox1.Text break; case 1: // Free for chat wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Chat, textBox1.Text); break; case 2: // Away wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Away, textBox1.Text); break; case 3: // Extended away wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.ExtendedAway, textBox1.Text); break; case 4: // Do not disturb wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.DoNotDisturb, textBox1.Text); break; case 5: // Invisible wodXMPP1.SetStatus(WODXMPPCOMLib.StatusEnum.Invisible, textBox1.Text); break; case 6: // Offline wodXMPP1.Disconnect(); break; } //Display current user status. Console.WriteLine(wodXMPP1.get_StatusText(wodXMPP1.Status)); } private void textBox1_TextChanged(object sender, EventArgs e) { comboBox1_SelectedIndexChanged(comboBox1, new System.EventArgs()); } |