none
vb.net开发gtalk RRS feed

  • 问题

  • 大家好,我用vb做了个简单gtalk的桌面程序,但是我把vb代码移植到网页上就不能运行了,这是怎么回事?谁有vb做的网页版gtalk示例


    enhua2008
    2010年8月14日 6:22

答案

全部回复

  • ”不能运行“不是问题的描述,是你下的结论。描述你运行时碰到的问题。

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    2010年8月17日 1:43
    版主
  • Imports agsXMPP
    'Imports Microsoft.Win32
    Public Class Form1
      Public U As String
      Public P As String
      Public M As String
      Public objXmpp As agsXMPP.XmppClientConnection
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
      End Sub
      Private Sub messageReceived(ByVal sender As Object, ByVal msg As protocol.client.Message)'收到消息自动回复,转到aspx.vb仍然成功
        Dim chatMessage() As String
        chatMessage = msg.From.ToString.Split("/")
        Dim jid As agsXMPP.Jid
        jid = New agsXMPP.Jid(chatMessage(0))
        Dim autoReply As protocol.client.Message
        autoReply = New protocol.client.Message(jid, protocol.client.MessageType.chat, mesage.Text)
        '''''''''''''''''''''''''''''''''''''''''''''''''''
    
        'Dim objXmpp As New agsXMPP.XmppClientConnection
        objXmpp.Send(autoReply)
        autoReply = New protocol.client.Message("**hua**@gmail.com", protocol.client.MessageType.chat, "OK,OK")
        objXmpp.Send(autoReply)
      End Sub
      Private Sub loginFailed()
        Me.Show()
        Label1.Text = "Login failed. Please check your details."
      End Sub
      Private Sub loggedIn()
        
        U = uname.Text.Trim
        P = pasd.Text.Trim
        M = mesage.Text
      End Sub
    
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
        Dim automaticstart As Boolean = False
        
        uname.Text = "x**a"
        pasd.Text = "1234"
        mesage.Text = "Hello"
        
        If CheckBox1.Checked = True Then
          automaticstart = True
        End If
    
        objXmpp = New agsXMPP.XmppClientConnection
        Dim jid As agsXMPP.Jid
        jid = New agsXMPP.Jid(uname.Text.Trim + "@gmail.com")
        objXmpp.Password = pasd.Text.Trim
        objXmpp.Username = jid.User
        objXmpp.Server = jid.Server
        objXmpp.AutoResolveConnectServer = True
    
        Try
          AddHandler objXmpp.OnMessage, AddressOf messageReceived
          AddHandler objXmpp.OnAuthError, AddressOf loginFailed
          AddHandler objXmpp.OnLogin, AddressOf loggedIn
          objXmpp.Open()
        Catch ex As Exception
          MsgBox(ex.Message)
        End Try
      End Sub
    
      Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click‘点击按钮发送一条消息,在此OK,转到aspx.vb不成功,对方收不到消息
        Dim msg As String
        msg = mesage.Text
        Dim Reply As protocol.client.Message
        Reply = New protocol.client.Message("**hua**@gmail.com", protocol.client.MessageType.chat, msg)
        objXmpp.Send(Reply)
        Reply = New protocol.client.Message("**hua**@gmail.com", protocol.client.MessageType.chat, "成功")
        objXmpp.Send(Reply)
      End Sub
    
    End Class
    
    

    enhua2008
    2010年8月17日 14:08
  • Imports agsXMPP
    Imports agsXMPP.Collections
    Imports agsXMPP.protocol
    Imports agsXMPP.protocol.client
    ''这是网页的aspx.vb代码
    Partial Class _Default
     Inherits System.Web.UI.Page
    
     Public chatmsg As String
     Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click '
      Dim objXmpp As agsXMPP.XmppClientConnection
      
      Dim userid As String = "x**a" '用此账号登陆给**hua**@gmail.com发消息
      Dim pswd As String = "1234"
      
      objXmpp = New agsXMPP.XmppClientConnection
      Dim jid As agsXMPP.Jid
      jid = New agsXMPP.Jid(userid + "@gmail.com")
      objXmpp.Password = pswd
      objXmpp.Username = jid.User
      objXmpp.Server = jid.Server
      objXmpp.AutoResolveConnectServer = True
    
      Dim msg As agsXMPP.protocol.client.Message = New agsXMPP.protocol.client.Message()
      msg.Type = agsXMPP.protocol.client.MessageType.chat
      msg.To = New Jid("**hua**@gmail.com")
      msg.Body = TextBox1.Text & "你好"
      
      Try
       AddHandler objXmpp.OnMessage, AddressOf messageReceived'这里是自动回复,对方收不到回复
       objXmpp.Open()
       Dim autoReply As protocol.client.Message
       autoReply = New protocol.client.Message("**hua**@gmail.com", protocol.client.MessageType.chat, chatmsg)
       objXmpp.Send(autoReply)
      Catch ex As Exception
       MsgBox(ex.Message)
      End Try
    
    
    
    
    
     End Sub
    
     Private Sub sendmessage(ByVal sendto As String, ByVal sendsms As String)
      Dim chatmsg As protocol.client.Message
      chatmsg = New protocol.client.Message(sendto, protocol.client.MessageType.chat, sendsms)
      'objXmpp.Send(chatmsg)
     End Sub
    
     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      
    
     End Sub
    
     Private Sub loginFailed(ByVal sender As Object, ByVal e As Xml.Dom.Element)
      Throw New NotImplementedException
     End Sub
    
     Private Sub messageReceived(ByVal sender As Object, ByVal msg As client.Message)
      Dim chatMessage() As String
      chatMessage = msg.From.ToString.Split("/")
      Dim jid As agsXMPP.Jid
      jid = New agsXMPP.Jid(chatMessage(0))
      Dim autoReply As protocol.client.Message
      autoReply = New protocol.client.Message(jid, protocol.client.MessageType.chat, "你好")
      '''''''''''''''''''''''''''''''''''''''''''''''''''
    
      Dim objXmpp As New agsXMPP.XmppClientConnection
      'objXmpp.Send(autoReply)
      autoReply = New protocol.client.Message("**hua**@gmail.com", protocol.client.MessageType.chat, chatmsg)
      objXmpp.Send(autoReply)
    
     End Sub
    
    End Class
    

    enhua2008
    2010年8月17日 14:25
  • 首先谢谢您的回复,如果您能帮我找出问题来,不胜感激
    enhua2008
    2010年8月17日 14:28
  • 你可以去http://forum.ag-software.de/forum.php?req=main&id=24找这个SDK的技术支持。

     



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    2010年8月17日 14:31
    版主
  • 因为postback, objXmpp是一个新对象吧

     

    你看看objXmpp.Username


    http://feiyun0112.cnblogs.com/
    2010年8月18日 1:13
    版主