private XmppClientConnection CreateXmppConnection(string xmppHost) { var connection = new XmppClientConnection { Server = xmppHost, ConnectServer = xmppHost, AutoResolveConnectServer = false, }; connection.OnLogin += o => hasLoggedIn.Set(); connection.OnMessage += (sender, msg) => { if( MessageType.chat.Equals(msg.Type)) OnChatMessageReceived(sender, msg); if (MessageType.error.Equals(msg.Type)) OnErrorMessagedReceived(sender, msg); }; connection.OnAuthError += (o, e) => error = ExceptionWithMsg(string.Format("Auth error {0}",e.ToString())); connection.OnSocketError += (o,e) => error = ExceptionWithMsg(string.Format("socket error {0}",e.ToString())); connection.OnStreamError += (o,e) => error = ExceptionWithMsg(string.Format("stream error {0}",e.ToString())); return connection; }