本文整理汇总了C#中agsXMPP.XmppClientConnection.Open方法的典型用法代码示例。如果您正苦于以下问题:C# XmppClientConnection.Open方法的具体用法?C# XmppClientConnection.Open怎么用?C# XmppClientConnection.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类agsXMPP.XmppClientConnection
的用法示例。
在下文中一共展示了XmppClientConnection.Open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public override Task Run()
{
_xmppConnection = new XmppClientConnection
{
Server = _host,
ConnectServer = _connectHost,
AutoResolveConnectServer = true,
Username = _username,
Password = _password,
};
_xmppConnection.OnLogin += OnLogin;
_xmppConnection.OnError += OnError;
_xmppConnection.OnMessage += OnMessage;
_xmppConnection.OnPresence += XmppConnectionOnOnPresence;
_xmppConnection.OnRosterItem += OnClientRosterItem;
CancelPreviousLogin();
_loginTcs = new TaskCompletionSource<bool>();
_xmppConnection.Open();
//return _loginTcs == null ? Task.FromResult(false) : _loginTcs.Task;
return Task.FromResult(false);
}
示例2: Conectar
public void Conectar(string user, string password)
{
XmppClientConnection xmpp = new XmppClientConnection("pvp.net");
xmpp.UseSSL = true;
xmpp.Port = 5223;
xmpp.Resource = "xiff";
xmpp.AutoResolveConnectServer = false;
xmpp.ConnectServer = "chat.euw1.lol.riotgames.com";
//Presence p = new Presence(ShowType.chat, "Online");
//p.Type = PresenceType.available;
//xmpp.Send(p);
xmpp.OnRosterItem += new XmppClientConnection.RosterHandler( xmpp_OnRosterItem);
xmpp.OnPresence += new PresenceHandler(xmpp_OnPresence);
xmpp.Open(user, "AIR_" + password);
//xmpp.OnLogin += delegate (object o) { MessageBox.Show("Logged in as " + xmpp.Username); };
System.Threading.Thread.Sleep(2000);
foreach (string nome in Contactos_Todos)
{
Offline_Friends.Items.Add(nome);
}
foreach (string nome in Contactos)
{
Online_Friends.Items.Add(nome);
}
button.Background = Brushes.Green;
button.IsEnabled = false;
button.Content = "CONECTED!";
}
示例3: RemakeXmpp
public static void RemakeXmpp()
{
if (Xmpp != null)
{
Xmpp.OnXmppConnectionStateChanged -= XmppOnOnXmppConnectionStateChanged;
Xmpp.Close();
Xmpp = null;
}
Xmpp = new XmppClientConnection(ServerPath);
Xmpp.RegisterAccount = false;
Xmpp.AutoAgents = true;
Xmpp.AutoPresence = true;
Xmpp.AutoRoster = true;
Xmpp.Username = XmppUsername;
Xmpp.Password = XmppPassword;
Xmpp.Priority = 1;
Xmpp.OnMessage += XmppOnOnMessage;
Xmpp.OnError += XmppOnOnError;
Xmpp.OnAuthError += new XmppElementHandler(Xmpp_OnAuthError);
Xmpp.OnStreamError += XmppOnOnStreamError;
Xmpp.KeepAlive = true;
Xmpp.KeepAliveInterval = 60;
Xmpp.OnAgentStart += XmppOnOnAgentStart;
Xmpp.OnXmppConnectionStateChanged += XmppOnOnXmppConnectionStateChanged;
Xmpp.Open();
}
示例4: Login
public void Login(string username, string password)
{
if (!LoggedIn)
{
try
{
_xmppClient = new XmppClientConnection("chat.facebook.com", 5222);
_xmppClient.OnXmppConnectionStateChanged += (sender, state) =>
{
if (OnConnectionStateChanged != null) OnConnectionStateChanged(state.ToString());
};
_xmppClient.UseStartTLS = true;
_xmppClient.OnPresence += UpdateContactList;
_xmppClient.OnLogin += OnLogin;
_xmppClient.OnAuthError += (sender, element) =>
{
if (OnAuthError != null) OnAuthError(element.ToString());
};
_xmppClient.Open(username, password);
}
catch
{
if (OnLoginResult != null)
OnLoginResult(false);
}
}
}
示例5: Start
public void Start()
{
AppDomain.CurrentDomain.AssemblyResolve += (o, args) =>
{
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
return loadedAssemblies.FirstOrDefault(asm => asm.FullName == args.Name);
};
string pluginsDirectory = Environment.CurrentDirectory + "\\plugins\\";
if (!Directory.Exists(pluginsDirectory))
{
Directory.CreateDirectory(pluginsDirectory);
}
_catalog = new DirectoryCatalog(Environment.CurrentDirectory + "\\plugins\\");
_catalog.Changed += new EventHandler<ComposablePartCatalogChangeEventArgs>(_catalog_Changed);
LoadPlugins();
_client = new XmppClientConnection(ConfigurationManager.AppSettings["Server"]);
//_client.ConnectServer = "talk.google.com"; //necessary if connecting to Google Talk
_client.AutoResolveConnectServer = false;
_client.OnLogin += new ObjectHandler(xmpp_OnLogin);
_client.OnMessage += new MessageHandler(xmpp_OnMessage);
_client.OnError += new ErrorHandler(_client_OnError);
Console.WriteLine("Connecting...");
_client.Resource = ConfigurationManager.AppSettings["Resource"];
_client.Open(ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Password"]);
Console.WriteLine("Connected.");
_client.OnRosterStart += new ObjectHandler(_client_OnRosterStart);
_client.OnRosterItem += new XmppClientConnection.RosterHandler(_client_OnRosterItem);
}
示例6: RiotChat
public RiotChat(string user, string pass)
{
xmpp = new XmppClientConnection();
roster = new List<Presence>();
xmpp.Username = user;
xmpp.Password = "AIR_" + pass;
xmpp.Server = "pvp.net";
xmpp.ConnectServer = "chat.na1.lol.riotgames.com";
xmpp.Port = 5223;
xmpp.AutoResolveConnectServer = false;
xmpp.UseCompression = false;
xmpp.UseStartTLS = false;
xmpp.UseSSL = true;
xmpp.OnAuthError += new XmppElementHandler(xmpp_OnEleError);
xmpp.OnError += new ErrorHandler(xmpp_OnError);
xmpp.OnStreamError += new XmppElementHandler(xmpp_OnEleError);
xmpp.OnSocketError += new ErrorHandler(xmpp_OnError);
xmpp.OnLogin += new ObjectHandler(xmpp_OnLogin);
xmpp.OnPresence += new PresenceHandler(xmpp_OnPresence);
xmpp.OnReadXml += new XmlHandler(xmpp_OnReadXML);
xmpp.OnWriteXml += new XmlHandler(xmpp_OnWriteXML);
xmpp.OnMessage += new MessageHandler(xmpp_OnMessage);
xmpp.Open();
}
示例7: JabberListener
public JabberListener()
{
Jid jidSender = new Jid(Properties.Settings.Default.JabberName);
xmpp = new XmppClientConnection(jidSender.Server);
xmpp.Open(jidSender.User, Properties.Settings.Default.JabberPWd);
xmpp.OnLogin += new ObjectHandler(xmpp_OnLogin);
}
示例8: StartRun
protected override void StartRun()
{
_client = new XmppClientConnection(Settings.Instance.JabberServer);
_client.Open(Settings.Instance.JabberUser, Settings.Instance.JabberPassword);
_client.OnLogin += delegate { UpdateState(0); };
_client.OnError += (sender, ex) => Log.Fatal("StartRun()", ex);
_client.OnAuthError += (sender, e) => Log.Fatal("StartRun() " + e);
}
示例9: 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();
}
示例10: Main
static void Main(string[] args)
{
Console.ReadLine();
XmppClientConnection xmppCon = new XmppClientConnection();
xmppCon.Username = "[email protected]";
xmppCon.Password = "aaaa";
xmppCon.Server = "talk.google.com";
xmppCon.Port = 443;
xmppCon.UseStartTLS = true;
xmppCon.AutoResolveConnectServer = true;
xmppCon.Open();
Console.WriteLine("Bye");
}
示例11: 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;
}
示例12: MainForm_Load
private void MainForm_Load(object sender, EventArgs e)
{
xmppCon = new XmppClientConnection();
xmppCon.OnLogin += new ObjectHandler(xmppCon_OnLogin);
xmppCon.OnAuthError += new XmppElementHandler(xmppCon_OnAuthError);
xmppCon.OnError += new ErrorHandler(xmppCon_OnError);
xmppCon.Username = "[email protected]";
xmppCon.Password = "751109";
xmppCon.Server = "talk.google.com";
xmppCon.Port = 443;
//xmppCon.UseStartTLS = true;
xmppCon.KeepAlive = true;
xmppCon.AutoResolveConnectServer = true;
xmppCon.Open();
}
示例13: Start
public void Start()
{
_client = new XmppClientConnection(_robot.Settings.Get("HipChatServer"))
{
AutoResolveConnectServer = false
};
_client.OnLogin += OnLogin;
_client.OnMessage += OnMessage;
_client.OnRosterStart += OnRosterStart;
_client.OnRosterItem += OnRosterItem;
_robot.Logger.WriteLine("Connecting...");
_client.Resource = _robot.Settings.Get("HipChatResource");
_client.Open(_robot.Settings.Get("HipChatUser"), _robot.Settings.Get("HipChatPassword"));
_robot.Logger.WriteLine("Connected.");
}
示例14: 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();
}
示例15: LOTROGateway
public LOTROGateway(string cserver, string server, string username, string password, string expectedUser, string confirmMsg, bool tls)
{
connection = new XmppClientConnection(server);
connection.ConnectServer = cserver;
connection.UseStartTLS = tls;
connection.OnMessage += new XmppClientConnection.MessageHandler(connection_OnMessage);
connection.OnLogin += new ObjectHandler(connection_OnLogin);
connection.OnError += new ErrorHandler(connection_OnError);
connection.OnClose += new ObjectHandler(connection_OnClose);
connection.OnPresence += new XmppClientConnection.PresenceHandler(connection_OnPresence);
connection.OnSocketError += new ErrorHandler(connection_OnSocketError);
this.username = username;
this.password = password;
connection.KeepAlive = true;
connection.Open(username, password);
this.expectedUser = expectedUser;
this.confirmMsg = confirmMsg;
}