/// <summary>
            /// Al abrirse la conexión socket
            /// </summary>
            protected override void OnOpen()
            {
                if (OnSocketOpen == null)
                {
                    return;
                }

                Debug.WriteLine(this, "Se establecio una nueva conexión socket: " + ID, VerbosityLevel.Default);

                SocketConnection socket = SelfSocketConnection();

                OnSocketOpen?.Invoke(this, socket);
            }
        /// <summary>
        /// Inicializar servidor socket en un puerto determinado
        /// </summary>
        /// <param name="port">Puerto a utilizar</param>
        public SocketServer(int port = 555)
        {
            var  config = ConfigurationManager.Get <ISocketAdapterConfiguration>();
            bool secure = Helper.SSL.Status == SSLCertificateStatus.Loaded && !config.OverrideSecure;

            m_webSocketServer = new WebSocketServer(port, secure);
            if (secure)
            {
                m_webSocketServer.SslConfiguration.EnabledSslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12;
                m_webSocketServer.SslConfiguration.ServerCertificate   = Helper.SSL.GlobalCertificate;
                Debug.WriteLine(this, "Inicializando SocketServer con SSL", VerbosityLevel.Info);
            }

            m_webSocketServer.AddWebSocketService("/", () =>
            {
                var socketBehaviour = new SocketBehaviour();

                socketBehaviour.OnSocketOpen  += (s, e) => OnSocketOpen?.Invoke(this, e);
                socketBehaviour.OnSocketClose += (s, e) => OnSocketClose?.Invoke(this, e);

                return(socketBehaviour);
            });
            m_webSocketServer.Start();
        }
예제 #3
0
 /// <summary>
 /// Event handler for opening socket
 /// </summary>
 private void Transport_OnSocketOpen()
 {
     OnSocketOpen?.Invoke();
 }
예제 #4
0
        /// <summary>
        /// Event handler for opening socket
        /// </summary>
        private void Socket_OnOpen(object sender, EventArgs e)
        {
            logger.Trace("{0}", JsonConvert.SerializeObject(e));

            OnSocketOpen?.Invoke();
        }