jabber.net不工作的vb.net [英] jabber.net not working for vb.net

查看:307
本文介绍了jabber.net不工作的vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用jabber.net Web应用
我知道这是一个桌面应用程序,如下面给出的链接给

i am trying to use jabber.net for web application i know this is for desktop application as given in below given link

http://www.$c$cproject.com/Articles/34300/Google-Chat-Desktop-Application-using-Jabber-Net

但我发现在栈溢出后与此相关的,它说一个家伙已经与Web应用程序实现了它。

but i found a post on stack overflow related to this and it say that one dude has implemented it with web application

<一个href=\"http://stackoverflow.com/questions/3226688/web-chat-application-asp-net-jabber-ajax-wcf-comet-reverseajax-issues-faced\">Web聊天应用程序 - ASP.NET/Jabber/Ajax/WCF/Comet/ReverseAjax - 面对的问题 - 寻找见解

实际上是code项目code的C#编写的

actually the code project code was written in 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像这样

so i converted it to vb.net like this

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

但它给我像错误

一个连接尝试失败,因为连接的方没有正确一段时间后响应或已建立的连接失败,因为连接主机未能响应。

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

请谢谢你们帮我提前

推荐答案

确认引用叽里咕噜-net.dll,zlib.net.dll和netlib.Dns.dll。

Make sure to reference jabber-net.dll, zlib.net.dll, and netlib.Dns.dll.

这篇关于jabber.net不工作的vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆