当前位置: 首页>>代码示例>>C#>>正文


C# XmppClientConnection.Send方法代码示例

本文整理汇总了C#中agsXMPP.XmppClientConnection.Send方法的典型用法代码示例。如果您正苦于以下问题:C# XmppClientConnection.Send方法的具体用法?C# XmppClientConnection.Send怎么用?C# XmppClientConnection.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在agsXMPP.XmppClientConnection的用法示例。


在下文中一共展示了XmppClientConnection.Send方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: XmppSendTest

 public void XmppSendTest()
 {
     var xmpp = new XmppClientConnection(domain);
     xmpp.ConnectServer = connectserver;
     xmpp.Open(username, password);
     xmpp.OnError += new ErrorHandler(delegate { logerror(); });
     xmpp.OnLogin += delegate(object o) { xmpp.Send(new Message(new Jid(recipient), MessageType.chat, "james")); };
     while (!xmpp.Authenticated)
         System.Threading.Thread.Sleep(500);
     System.Threading.Thread.Sleep(1000);
     xmpp.Send(new Message(new Jid(recipient), MessageType.chat, "james"));
     xmpp.Close();
 }
开发者ID:jamessantiago,项目名称:agsXmppNlogTarget,代码行数:13,代码来源:UnitTest1.cs

示例2: Init

        public override void Init(XmppClientConnection con)
        {
            m_XmppClient = con;

            // <auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">$Message</auth>
            m_XmppClient.Send(new protocol.sasl.Auth(protocol.sasl.MechanismType.PLAIN, Message()));
        }
开发者ID:jptoto,项目名称:argsxmpp,代码行数:7,代码来源:PlainMechanism.cs

示例3: AuthenticateAsync

        public async Task<Session.IInfo> AuthenticateAsync(string connectServer, string authenticationToken)
        {
            XmppClientConnection connection = new XmppClientConnection();

            connection.Server = Guest.Server;
            connection.Username = Guest.User;
            connection.Password = GuestPassword;

            connection.AutoResolveConnectServer = false;
            connection.ForceStartTls = false;
            connection.ConnectServer = connectServer; // values.HarmonyHubAddress;
            connection.AutoAgents = false;
            connection.AutoPresence = false;
            connection.AutoRoster = false;
            connection.OnSaslStart += OnSaslStart;
            connection.OnSaslEnd += OnSaslEnd;
            connection.OnXmppConnectionStateChanged += (s, e) => Instrumentation.Xmpp.ConnectionStateChanged(e);
            connection.OnReadXml += (s, e) => Instrumentation.Xmpp.Receive(e);
            connection.OnWriteXml += (s, e) => Instrumentation.Xmpp.Transmit(e);
            connection.OnError += (s, e) => Instrumentation.Xmpp.Error(e);
            connection.OnSocketError += (s, e) => Instrumentation.Xmpp.SocketError(e);

            Task connected = Observable.FromEvent<agsXMPP.ObjectHandler, Unit>(handler => s => handler(Unit.Default), handler => connection.OnLogin += handler, handler => connection.OnLogin -= handler)
                                       .Timeout(TimeSpan.FromSeconds(30))
                                       .Take(1)
                                       .ToTask();

            connection.Open();

            await connected;

            Task<Session.IInfo> session =
                Observable.FromEvent<agsXMPP.protocol.client.IqHandler, agsXMPP.protocol.client.IQEventArgs>(handler => (s, e) => handler(e), handler => connection.OnIq += handler, handler => connection.OnIq -= handler)
                      .Do(args => Instrumentation.Xmpp.IqReceived(args.IQ.From, args.IQ.To, args.IQ.Id, args.IQ.Error, args.IQ.Type, args.IQ.Value))
                      .Do(args => args.Handled = true)
                      .Select(args => args.IQ)
                      .SessionResponses()
                      .Timeout(TimeSpan.FromSeconds(10))
                      .Take(1)
                      .ToTask();

            connection.Send(Builder.ConstructSessionInfoRequest(authenticationToken));

            Session.IInfo sessionInfo = await session;

            connection.Close();

            return sessionInfo;
        }
开发者ID:Zananok,项目名称:Harmonize,代码行数:49,代码来源:Provider.cs

示例4: Send

 public Task<ContactDetails> Send()
 {
     var dispatcher = Dispatcher.CurrentDispatcher;
     var connection = ConnectionManager.GetOrCreateConnection(_client);
     _onIq = dispatcher.Wrap<object, IQ>(OnIq);
     _connection = connection.Connection;
     _connection.OnIq += _onIq.Exec;
     var iq = new VcardIq();
     iq.Type = IqType.get;
     iq.To = _jid;
     iq.From = _connection.MyJID;
     iq.Id = _id = Guid.NewGuid().ToString("N");
     _connection.Send(iq);
     return _task.Task;
 }
开发者ID:Irdis,项目名称:VSTalk,代码行数:15,代码来源:ContactInfoRequest.cs

示例5: Main

        static void Main(string[] args)
        {           
            const string JID_SENDER     = "[email protected]";
            const string PASSWORD       = "secret";   // password of the JIS_SENDER account

            const string JID_RECEIVER   = "[email protected]";

            Jid jidSender = new Jid(JID_SENDER);
            XmppClientConnection xmpp = new  XmppClientConnection(jidSender.Server);
            xmpp.Open(jidSender.User, PASSWORD);            
            xmpp.OnLogin += delegate(object o) { xmpp.Send(new Message(new Jid(JID_RECEIVER), MessageType.chat, "Hello, how are you?")); };

            Console.WriteLine("Wait until you get the message and press a key to continue");
            Console.ReadLine();
            
            xmpp.Close();
        }
开发者ID:don59,项目名称:agsXmpp,代码行数:17,代码来源:Program.cs

示例6: GTalk

        /// <summary>
        /// Attempts to send a gTalk IM to the specified account.
        /// </summary>
        public void GTalk(string username, string password, string sendToUser, string message, int connectionTimeout)
        {
            try
            {
                if (connectionTimeout > GTALK_MAX_CONNECTION_TIMEOUT)
                {
                    connectionTimeout = GTALK_MAX_CONNECTION_TIMEOUT;
                }
                else if (connectionTimeout < GTALK_DEFAULT_CONNECTION_TIMEOUT)
                {
                    connectionTimeout = GTALK_DEFAULT_CONNECTION_TIMEOUT;
                }

                XmppClientConnection xmppCon = null;

                if (m_gtalkConnections.ContainsKey(username))
                {
                    xmppCon = m_gtalkConnections[username];
                    Log("Using existing gTalk connection for " + username + "@gmail.com.");
                    xmppCon.Send(new Message(new Jid(sendToUser + "@gmail.com"), MessageType.chat, message));
                }
                else
                {
                    xmppCon = new XmppClientConnection();
                    xmppCon.Password = password;
                    xmppCon.Username = username;
                    xmppCon.Server = "gmail.com";
                    xmppCon.ConnectServer = "talk.google.com";
                    xmppCon.AutoAgents = false;
                    xmppCon.AutoPresence = false;
                    xmppCon.AutoRoster = false;
                    xmppCon.AutoResolveConnectServer = true;

                    Log("Attempting to connect to gTalk for " + username + ".");

                    ManualResetEvent waitForConnect = new ManualResetEvent(false);

                    xmppCon.OnLogin += new ObjectHandler((sender) => waitForConnect.Set());
                    xmppCon.Open();

                    if (waitForConnect.WaitOne(connectionTimeout, false))
                    {
                        Log("Connected to gTalk for " + username + "@gmail.com.");
                        if (!m_gtalkConnections.ContainsKey(username))
                        {
                            m_gtalkConnections.Add(username, xmppCon);
                        }
                        xmppCon.Send(new Message(new Jid(sendToUser + "@gmail.com"), MessageType.chat, message));
                    }
                    else
                    {
                        Log("Connection to gTalk for " + username + " timed out.");
                    }
                }
                //xmppCon.Close();
            }
            catch (Exception excp)
            {
                logger.Error("Exception GTalk. " + excp.Message);
                Log("Exception GTalk. " + excp.Message);
            }
        }
开发者ID:Dawn2Yuan,项目名称:sipsorcery,代码行数:65,代码来源:DialPlanScriptFacade.cs

示例7: Init

 /// <summary>
 /// 
 /// </summary>
 /// <param name="con"></param>
 public override void Init(XmppClientConnection con)
 {
     con.Send(new Auth(MechanismType.ANONYMOUS));
 }
开发者ID:phiree,项目名称:dzdocs,代码行数:8,代码来源:AnonymousMechanism.cs

示例8: Main

        static void Main(string[] args)
        {
            XmppClientConnection xmppCon = new XmppClientConnection();

            Console.Title = "Console Client";

            // read the jid from the console
            PrintHelp("Enter you Jid ([email protected]): ");
            Jid jid = new Jid(Console.ReadLine());

            PrintHelp(String.Format("Enter password for '{0}': ", jid.ToString()));

            xmppCon.Password = Console.ReadLine();
            xmppCon.Username = jid.User;
            xmppCon.Server = jid.Server;
            xmppCon.AutoAgents = false;
            xmppCon.AutoPresence = true;
            xmppCon.AutoRoster = true;
            xmppCon.AutoResolveConnectServer = true;

            // Connect to the server now
            // !!! this is asynchronous !!!
            try
            {
                xmppCon.OnRosterStart += new ObjectHandler(xmppCon_OnRosterStart);
                xmppCon.OnRosterItem += new XmppClientConnection.RosterHandler(xmppCon_OnRosterItem);
                xmppCon.OnRosterEnd += new ObjectHandler(xmppCon_OnRosterEnd);
                xmppCon.OnPresence += new PresenceHandler(xmppCon_OnPresence);
                xmppCon.OnMessage += new MessageHandler(xmppCon_OnMessage);
                xmppCon.OnLogin += new ObjectHandler(xmppCon_OnLogin);

                xmppCon.Open();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Wait("Login to server, please wait");

            PrintCommands();

            bool bQuit = false;

            while (!bQuit)
            {
                string command = Console.ReadLine();
                string[] commands = command.Split(' ');

                switch (commands[0].ToLower())
                {
                    case "help":
                        PrintCommands();
                        break;
                    case "quit":
                        bQuit = true;
                        break;
                    case "msg":
                        string msg = command.Substring(command.IndexOf(commands[2]));
                        xmppCon.Send(new Message(new Jid(commands[1]), MessageType.chat, msg));
                        break;
                    case "status":
                        switch (commands[1])
                        {
                            case "online":
                                xmppCon.Show = ShowType.NONE;
                                break;
                            case "away":
                                xmppCon.Show = ShowType.away;
                                break;
                            case "xa":
                                xmppCon.Show = ShowType.xa;
                                break;
                            case "chat":
                                xmppCon.Show = ShowType.chat;
                                break;
                        }
                        string status = command.Substring(command.IndexOf(commands[2]));
                        xmppCon.Status = status;
                        xmppCon.SendMyPresence();
                        break;
                }
            }

            // close connection
            xmppCon.Close();
        }
开发者ID:phiree,项目名称:dzdocs,代码行数:88,代码来源:Program.cs

示例9: Main

        static void Main(string[] args) {
            Console.Title = "XMPPduino";

            xmppCon = new XmppClientConnection();

            System.ComponentModel.IContainer components = new System.ComponentModel.Container();
            serialPort = new System.IO.Ports.SerialPort(components);

            serialPort.PortName = Config.COM_PORT;
            serialPort.BaudRate = Config.Baud_Rate;

            xmppCon = new XmppClientConnection();
            xmppCon.Username = Config.Username;
            xmppCon.Password = Config.Password;
            xmppCon.SocketConnectionType = agsXMPP.net.SocketConnectionType.Direct;
            xmppCon.ConnectServer = "talk.google.com";
            xmppCon.Port = 5222;
            xmppCon.UseStartTLS = true;
            xmppCon.AutoResolveConnectServer = false;
            xmppCon.Show = ShowType.chat;
            xmppCon.Server = Config.Server;

            xmppCon.AutoAgents = false;
            xmppCon.AutoPresence = true;
            xmppCon.AutoRoster = true;

            try {
                xmppCon.OnRosterStart += new ObjectHandler(xmppCon_OnRosterStart);
                xmppCon.OnRosterItem += new XmppClientConnection.RosterHandler(xmppCon_OnRosterItem);
                xmppCon.OnRosterEnd += new ObjectHandler(xmppCon_OnRosterEnd);
                xmppCon.OnPresence += new PresenceHandler(xmppCon_OnPresence);
                xmppCon.OnMessage += new MessageHandler(xmppCon_OnMessage);
                xmppCon.OnLogin += new ObjectHandler(xmppCon_OnLogin);
                xmppCon.Open();
            }
            catch (Exception e) {
                Console.WriteLine(e.Message);
            }

            Wait("Login to server, please wait");
            bool bQuit = false;

            while (!bQuit) {
                string command = Console.ReadLine();
                string[] commands = command.Split(' ');

                switch (commands[0].ToLower()) {
                    case "quit":
                        bQuit = true;
                        break;
                    case "msg":
                        string msg = command.Substring(command.IndexOf(commands[2]));
                        xmppCon.Send(new Message(new Jid(commands[1]), MessageType.chat, msg));
                        break;
                    case "status":
                        switch (commands[1]) {
                            case "online":
                                xmppCon.Show = ShowType.NONE;
                                break;
                            case "away":
                                xmppCon.Show = ShowType.away;
                                break;
                            case "xa":
                                xmppCon.Show = ShowType.xa;
                                break;
                            case "chat":
                                xmppCon.Show = ShowType.chat;
                                break;
                        }
                        string status = command.Substring(command.IndexOf(commands[2]));
                        xmppCon.Status = status;
                        xmppCon.SendMyPresence();
                        break;
                }
            }
            xmppCon.Close();
        }
开发者ID:tfreedman,项目名称:Transceiver.ino,代码行数:77,代码来源:Program.cs


注:本文中的agsXMPP.XmppClientConnection.Send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。