/**
         * @Method constructor that initializates the Secure WebSocket on default port 1443
         */
        public SecureSuperSocketController()
        {
            this.Log = LogManager.GetLogger(Properties.Settings.Default.logName);
            int port = 1443;
            SuperSocket.SocketBase.Config.RootConfig r = new SuperSocket.SocketBase.Config.RootConfig();

            SuperSocket.SocketBase.Config.ServerConfig s = new SuperSocket.SocketBase.Config.ServerConfig();

            //Using 80 or 9999 port is working

            s.Name = "SuperWebSocket";
            s.Ip = "127.0.0.1";
            s.Port = port;
            s.Mode = SocketMode.Tcp;
            s.Security = "tls";

            SuperSocket.SocketBase.Config.CertificateConfig cert = new SuperSocket.SocketBase.Config.CertificateConfig();

            string pathToBaseDir = System.IO.Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;

            cert.FilePath = System.IO.Path.Combine(pathToBaseDir, "galeonssl.pfx");
            System.Diagnostics.Debug.Assert(System.IO.File.Exists(cert.FilePath));
            cert.Password = "******";

            s.Certificate = cert;

            SuperSocket.SocketEngine.SocketServerFactory f = new SuperSocket.SocketEngine.SocketServerFactory();

            base.appServer = new WebSocketServer();
            try
            {
                base.appServer.Setup(r, s, f);
                Log.Debug("Secure WebSocket Started at port " + port);
                base.appServer.NewMessageReceived += new SessionHandler<WebSocketSession, string>(this.appServer_NewMessageReceived);
            }
            catch (Exception ex)
            {
                Log.Error("Error while creating Socket on port " + port, ex);
                this.appServer = null;
            }
        }
Beispiel #2
0
        private SuperSocket.SocketBase.Config.ServerConfig buildServerConfig(int port)
        {
            string pathToBaseDir = System.IO.Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
            var    cert          = new SuperSocket.SocketBase.Config.CertificateConfig()
            {
                FilePath = "localhost.pfx", //System.IO.Path.Combine(pathToBaseDir, "localhost.pfx"),
                Password = "******"
            };
            var config = new SuperSocket.SocketBase.Config.ServerConfig()
            {
                Port = port,
                Ip   = "Any",
                MaxConnectionNumber = 100,
                Mode        = SuperSocket.SocketBase.SocketMode.Tcp,
                Name        = "GazeServer",
                Security    = "tls",
                Certificate = cert
            };

            return(config);
        }