LiveCodingChat.Livecoding.ChatRoom.Login C# (CSharp) Метод

Login() публичный Метод

public Login ( ) : void
Результат void
        public void Login()
        {
            if (Client == null) {
                if (LoadXMPPData ()) {
                    Client = new LiveCodingChat.Xmpp.XmppTest (this);
                    Room = new LiveCodingChat.Xmpp.Room (ID, Client);
                    Client.XmppAuthenticated += (object sender, EventArgs e) => {
                        Client.Rooms.Add(Room.ID+"@chat.livecoding.tv",Room);
                        Room.JoinRoom ();
                        Room.QueryInfo ();
                        Room.SendPresence ();
                    };
                } else {
                    //Session.Authenticated = false;
                }
            }
        }

Usage Example

Пример #1
0
        private ChatRoom OpenChat(string room)
        {
            string         url = PAGE + "chat/" + room + "/";
            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);

            req.UserAgent       = UserAgent;
            req.CookieContainer = cookies;
            HttpWebResponse response = (HttpWebResponse)req.GetResponse();

            if (response.StatusCode == HttpStatusCode.OK)
            {
                ChatRoom chatRoom = new ChatRoom(this, room);
                using (System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream())) {
                    string data = sr.ReadToEnd();
                    int    fInd = data.IndexOf("window.Chat.init(");
                    //Console.WriteLine (data);
                    if (fInd == -1)
                    {
                        return(null);
                    }
                    Console.WriteLine("Found start");
                    fInd += "window.Chat.init(".Length;
                    int eInd = data.IndexOf(");", fInd);
                    if (eInd == -1)
                    {
                        return(null);
                    }
                    Console.WriteLine("Found end");
                    string json = data.Substring(fInd, eInd - fInd - 1);
                    fInd = data.IndexOf("window.Chat.connect(", eInd);
                    if (fInd == -1)
                    {
                        return(null);
                    }
                    eInd = data.IndexOf(");", fInd);
                    if (eInd == -1)
                    {
                        return(null);                       //TODO: exception trowing?
                    }
                    string tmp = data.Substring(fInd, eInd - fInd - 1);
                    tmp = tmp.Split(',') [1];
                    tmp = tmp.Split(':') [1].Trim().Replace("\"", "");
                    chatRoom.Load(json, tmp);
                }
                chatRoom.Login();
                return(chatRoom);
            }
            Console.WriteLine("Not OK");
            return(null);
        }
All Usage Examples Of LiveCodingChat.Livecoding.ChatRoom::Login