Exemplo n.º 1
0
        /// <summary>
        /// 连接Rmtp服务
        /// </summary>
        /// <param name="pIp">Rmtp目标IP</param>
        /// <param name="pPort">端口号</param>
        public void ConnectRmtpService(RmtpCommand pCmd)
        {
            string pIp   = ConfigurationManager.AppSettings["IP"];
            int    pPort = int.Parse(ConfigurationManager.AppSettings["Port"]);

            if (_rmtpControler != null && _rmtpControler.IsConnected)
            {
                return;
            }

            if (_rmtpDataFrameCache != null)
            {
                _rmtpDataFrameCache.ReceiveDataFrame -= OnReceiveDataFrame;
                _rmtpDataFrameCache = null;
            }

            _rmtpDataFrameCache = new RmtpDataFrameCache(pCmd);
            _rmtpDataFrameCache.ReceiveDataFrame += OnReceiveDataFrame;

            if (_rmtpControler != null)
            {
                _rmtpControler.Close();
                _rmtpControler.SocketConnected -= OnRmtpConnected;
                _rmtpControler.SocketError     -= OnRmtpError;
                _rmtpControler = null;
            }

            _rmtpControler = new SocketController(pIp, pPort, _rmtpDataFrameCache);
            _rmtpControler.SocketConnected += OnRmtpConnected;
            _rmtpControler.SocketError     += OnRmtpError;

            _rmtpControler.Connect();
        }
Exemplo n.º 2
0
        public async Task <bool> Connect()
        {
            bool connected = await SocketController.Connect("wss://gateway.discord.gg/?v=6&encoding=json");

            SocketListener.Listen();
            return(connected);
        }