我正在尝试将 jabber.net 用于 Web 应用程序我知道这是用于桌面应用程序,如下面给出的链接所示
http://www.codeproject.com/Articles/34300/Google-Chat-Desktop-Application-using-Jabber-Net
但我发现了一篇关于堆栈溢出的帖子,上面说有一个家伙已经用 Web 应用程序实现了它
网络聊天应用程序 - ASP.NET/Jabber/Ajax/WCF/Comet/ReverseAjax - 面临的问题 - 寻求见解
实际上代码项目代码是用c#编写的
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using jabber.client;
using System.Threading;
using jabber.protocol.iq;
using jabber;
using Google.GData.Contacts;
using Google.GData.Extensions;
using jabber.protocol;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
static ManualResetEvent done = new ManualResetEvent(false);
private jabber.client.JabberClient jabberClient1=new jabber.client.JabberClient();
protected void Page_Load(object sender, EventArgs e)
{
jabberClient1.OnMessage += new MessageHandler(jabberClient1_OnMessage);
jabberClient1.OnDisconnect += new bedrock.ObjectHandler(jabberClient1_OnDisconnect);
jabberClient1.OnError += new bedrock.ExceptionHandler(jabberClient1_OnError);
jabberClient1.OnAuthError += new jabber.protocol.ProtocolHandler(jabberClient1_OnAuthError);
jabberClient1.User = "sa";
jabberClient1.Server = "gmail.com";
jabberClient1.Password = "download";
jabberClient1.Connect();
jabberClient1.OnAuthenticate += new bedrock.ObjectHandler(jabberClient1_OnAuthenticate);
}
void jabberClient1_OnAuthenticate(object sender)
{
done.Set();
}
void jabberClient1_OnAuthError(object sender, System.Xml.XmlElement rp)
{
if (rp.Name == "failure")
{
Response.Write("Invalid User Name or Password");
}
}
void jabberClient1_OnError(object sender, Exception ex)
{
Response.Write(ex.Message);
}
void jabberClient1_OnDisconnect(object sender)
{
Response.Write("Disconnected");
}
private void jabberClient1_OnMessage(object sender, jabber.protocol.client.Message msg)
{
Response.Write("Message Posted");
//frmChat[(int)chatIndex[msg.From.Bare]].ReceiveFlag = true;
//string receivedMsg = msg.From.User + " Says : " + msg.Body + "\n";
//frmChat[(int)chatIndex[msg.From.Bare]].AppendConversation(receivedMsg);
//frmChat[(int)chatIndex[msg.From.Bare]].Show();
}
}
}
所以我像这样将它转换为vb.net
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports jabber.client
Imports System.Threading
Imports jabber.protocol.iq
Imports jabber
Imports Google.GData.Contacts
Imports Google.GData.Extensions
Imports jabber.protocol
Public Class GtalkIntegration
Inherits System.Web.UI.Page
Shared done As New ManualResetEvent(False)
Private WithEvents jabberClient1 As New jabber.client.JabberClient()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddHandler jabberClient1.OnMessage, AddressOf jabberClient1_OnMessage
AddHandler jabberClient1.OnDisconnect, AddressOf jabberClient1_OnDisconnect
AddHandler jabberClient1.OnError, AddressOf jabberClient1_OnError
AddHandler jabberClient1.OnAuthError, AddressOf jabberClient1_OnAuthError
jabberClient1.User = "sa"
jabberClient1.Server = "gmail.com"
jabberClient1.Password = "download"
jabberClient1.Connect()
AddHandler jabberClient1.OnAuthenticate, AddressOf jabberClient1_OnAuthenticate
End Sub
Private Sub jabberClient1_OnAuthenticate(ByVal sender As Object)
done.[Set]()
End Sub
Private Sub jabberClient1_OnAuthError(ByVal sender As Object, ByVal rp As System.Xml.XmlElement)
If rp.Name = "failure" Then
Response.Write("Invalid User Name or Password")
End If
End Sub
Private Sub jabberClient1_OnError(ByVal sender As Object, ByVal ex As Exception)
Response.Write(ex.Message)
End Sub
Private Sub jabberClient1_OnDisconnect(ByVal sender As Object)
Response.Write("Disconnected")
End Sub
Private Sub jabberClient1_OnMessage(ByVal sender As Object, ByVal msg As jabber.protocol.client.Message)
Response.Write("Message Posted")
'frmChat[(int)chatIndex[msg.From.Bare]].ReceiveFlag = true;
'string receivedMsg = msg.From.User + " Says : " + msg.Body + "\n";
'frmChat[(int)chatIndex[msg.From.Bare]].AppendConversation(receivedMsg);
'frmChat[(int)chatIndex[msg.From.Bare]].Show();
End Sub
End Class
但它给了我这样的错误
连接尝试失败,因为连接的一方在一段时间后没有正确响应,或者连接失败,因为连接的主机没有响应
请帮帮我提前谢谢