Пример #1
0
        public void Connect()
        {
            //not sure if this socket will work but it should work...
            sslsocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //create socket pointing at variable server and port 2099
            IPHostEntry hostEntry = Dns.GetHostEntry(server);
            IPEndPoint  ipe       = new IPEndPoint(hostEntry.AddressList.First(), 2099);

            sslsocket.Connect(ipe);


            input  = new NetworkStream(sslsocket);
            output = new BufferedStream(input);

            doHandshake();

            // Start reading responses
            pr = new RTMPPacketReader(input);

            // Handle preconnect Messages?
            // -- 02 | 00 00 00 | 00 00 05 | 06 00 00 00 00 | 00 03 D0 90 02

            // Connect
            Dictionary <String, Object> parameters = new Dictionary <String, Object>();

            parameters.Add("app", app);
            parameters.Add("flashVer", "WIN 10,1,85,3");
            parameters.Add("swfUrl", swfUrl);
            parameters.Add("tcUrl", "rtmps://" + server + ":" + port);
            parameters.Add("fpad", false);
            parameters.Add("capabilities", 239);
            parameters.Add("audioCodecs", 3191);
            parameters.Add("videoCodecs", 252);
            parameters.Add("videoFunction", 1);
            parameters.Add("pageUrl", pageUrl);
            parameters.Add("objectEncoding", 3);

            try
            {
                byte[] connect = aec.encodeConnect(parameters);

                // note NetworkStream doesn't have a reliable Flush() method. anything in Write Method will immediately be sent to server.
                output.Write(connect, 0, connect.Length);
                output.Flush();

                TypedObject result = pr.GetPacket(1);
                TypedObject body   = (TypedObject)result["body"];
                DSId = (string)body["id"];

                connected = true;
            }
            catch (Exception e)
            {
                throw new Exception("Error encoding or decoding", e);
            }
        }
Пример #2
0
        public void Connect()
        {

            //not sure if this socket will work but it should work...
            sslsocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //create socket pointing at variable server and port 2099
            IPHostEntry hostEntry = Dns.GetHostEntry(server);
            IPEndPoint ipe = new IPEndPoint(hostEntry.AddressList.First(), 2099);
            sslsocket.Connect(ipe);


            input = new NetworkStream(sslsocket);
            output = new BufferedStream(input);
            
            doHandshake();

            // Start reading responses
            pr = new RTMPPacketReader(input);

            // Handle preconnect Messages?
            // -- 02 | 00 00 00 | 00 00 05 | 06 00 00 00 00 | 00 03 D0 90 02

            // Connect
            Dictionary<String, Object> parameters = new Dictionary<String, Object>();
            parameters.Add("app", app);
            parameters.Add("flashVer", "WIN 10,1,85,3");
            parameters.Add("swfUrl", swfUrl);
            parameters.Add("tcUrl", "rtmps://" + server + ":" + port);
            parameters.Add("fpad", false);
            parameters.Add("capabilities", 239);
            parameters.Add("audioCodecs", 3191);
            parameters.Add("videoCodecs", 252);
            parameters.Add("videoFunction", 1);
            parameters.Add("pageUrl", pageUrl);
            parameters.Add("objectEncoding", 3);

            try
            {
                byte[] connect = aec.encodeConnect(parameters);

                // note NetworkStream doesn't have a reliable Flush() method. anything in Write Method will immediately be sent to server.
                output.Write(connect, 0, connect.Length);
                output.Flush();

                TypedObject result = pr.GetPacket(1);
                TypedObject body = (TypedObject)result["body"];
                DSId = (string)body["id"];

                connected = true;
            }
            catch (Exception e)
            {
                throw new Exception("Error encoding or decoding", e);
            }
        }