Beispiel #1
0
        public XmppTest(Livecoding.ChatRoom client)
        {
            Rooms     = new Dictionary <string, Room> ();
            IDManager = new IDManager();
            JID       = client.JID;
            Password  = client.Password;
            ressource = client.Resource;
            Nick      = JID.Split('@') [0];

            keepAliveTimer          = new System.Timers.Timer(1000 * 60);
            keepAliveTimer.Elapsed += KeepAliveTimer_Elapsed;
            messageTypes            = new Dictionary <string, XMPPMessage> ();
            iqMethods = new Dictionary <string, XMPPMessage> ();
            messageTypes.Add("open", XMPP_Open);
            messageTypes.Add("stream:features", XMPP_Features);
            messageTypes.Add("success", XMPP_Success);
            messageTypes.Add("iq", XMPP_IQ);
            messageTypes.Add("close", XMPP_Close);
            messageTypes.Add("message", XMPP_Message);
            messageTypes.Add("presence", XMPP_Presence);


            List <KeyValuePair <string, string> > customHeaders = new List <KeyValuePair <string, string> >();

            customHeaders.Add(new KeyValuePair <string, string>("Sec-WebSocket-Extensions", "permessage-deflate"));
            string origin    = "https://www.livecoding.tv";         //TODO:
            string UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";

            uri    = "wss://www.livecoding.tv:443" + client.WebsocketURL;
            socket = new WebSocket(uri, "xmpp", HttpHelper.ConvertCookies(client.Session.Cookies), customHeaders, UserAgent, origin);
            socket.MessageReceived += Socket_MessageReceived;
            socket.Open();
            socket.Opened += Socket_Opened;
        }