示例#1
0
        public void Connect(int port, conn_info ci)
        {
            if (TC.Connected == true)
            {
                throw new Exception("이미 연결되어 있습니다.");
            }
            if (ci.room == null || ci.room == "")
            {
                throw new Exception("방 이름이 설정되어 있지 않습니다.");
            }
            if (ci.nick == null || ci.nick == "")
            {
                throw new Exception("닉네임이 설정되어 있지 않습니다.");
            }
            this.ci = ci;
            TC.Connect("chat.uchat.co.kr", port);

            byte[] buf = System.Text.Encoding.UTF8.GetBytes("GET /socket.io/1/websocket/" + time_token(port.ToString()) + " HTTP/1.1\r\nHost: chat.uchat.co.kr:" + port.ToString() + "\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nUser-Agent: UChat_Bot\r\nSec-WebSocket-Key: RV9TdWttZWFuJ3MgVUNoYXQgV2ViU29ja2V0TGli\r\nOrigin: https://www.esukmean.com\r\nSec-WebSocket-Version: 13\r\n\r\n");
            TC.GetStream().Write(buf, 0, buf.Length);

            State       = WebSockState.Connecting;
            Recv_Thread = new System.Threading.Thread(monitor);
            Recv_Thread.Start();
        }
示例#2
0
        public void Connect(int port, conn_info ci)
        {
            if (TC.Connected == true) throw new Exception("이미 연결되어 있습니다.");
            if (ci.room == null || ci.room == "") throw new Exception("방 이름이 설정되어 있지 않습니다.");
            if (ci.nick == null || ci.nick == "") throw new Exception("닉네임이 설정되어 있지 않습니다.");
            this.ci = ci;
            TC.Connect("chat.uchat.co.kr", port);

            byte[] buf = System.Text.Encoding.UTF8.GetBytes("GET /socket.io/1/websocket/" + time_token(port.ToString()) + " HTTP/1.1\r\nHost: chat.uchat.co.kr:" + port.ToString() + "\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nUser-Agent: UChat_Bot\r\nSec-WebSocket-Key: RV9TdWttZWFuJ3MgVUNoYXQgV2ViU29ja2V0TGli\r\nOrigin: https://www.esukmean.com\r\nSec-WebSocket-Version: 13\r\n\r\n");
            TC.GetStream().Write(buf, 0, buf.Length);

            State = WebSockState.Connecting;
            Recv_Thread = new System.Threading.Thread(monitor);
            Recv_Thread.Start();
        }