Esempio n. 1
0
        static void Main()
        {
            UserManager.Init();
            WebSocketFactory.Init(() => new WebSocketConnection());
            if (int.TryParse(ConfigurationManager.AppSettings["InsecureServerPort"], out int insecurePort))
            {
                var insecureServer = new WebSocketServer(insecurePort);
                insecureServer.AddWebSocketService <Connection>("/");
                insecureServer.KeepClean = false;
                insecureServer.Start();
            }
            if (int.TryParse(ConfigurationManager.AppSettings["SecureServerPort"], out int securePort))
            {
                var server = new WebSocketServer(securePort, true)
                {
                    SslConfiguration = { ServerCertificate = new X509Certificate2(ConfigurationManager.AppSettings["CertificateFile"], ConfigurationManager.AppSettings["CertificatePassword"]) }
                };
                server.AddWebSocketService <Connection>("/");
                server.KeepClean = false;
                server.Start();
            }
            var kill = new ManualResetEvent(false);

            Console.CancelKeyPress += delegate { kill.Set(); };
            kill.WaitOne();
        }
        public BrokerConnection(string uri, string realm)
        {
            WebSocketFactory.Init(() => new ClientWebSocketConnection());

            _channel = new WampChannelFactory()
                       .ConnectToRealm(realm)
                       .WebSocketTransport(uri)
                       .JsonSerialization()
                       .Build();

            Func <Task> connect = async() =>
            {
                Log.Information("Trying to connect to broker {brokerUri}", uri);

                try
                {
                    await _channel.Open();

                    Log.Debug("Connection Opened.");

                    _subject.OnNext(Connected.Yes(new Broker(_channel)));
                }
                catch (Exception exception)
                {
                    Log.Error(exception, "Connection Failed.");

                    _subject.OnNext(Connected.No <IBroker>());
                    throw exception;
                }
            };

            _reconnector = new WampChannelReconnector(_channel, connect);
        }
Esempio n. 3
0
 public TestBroker()
 {
     WebSocketFactory.Init(() => new ClientWebSocketConnection());
     _channel = new WampChannelFactory()
                .ConnectToRealm("com.weareadaptive.reactivetrader")
                .WebSocketTransport(TestAddress.Broker)
                .JsonSerialization()
                .Build();
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            WebSocketFactory.Init(() => new WebSocketConnection());
            AppDomain.CurrentDomain.UnhandledException += (_, e) => File.AppendAllText("crash.log", DateTime.Now + "\r\n" + e.ExceptionObject + "\r\n\r\n");
            userName = ConfigurationManager.AppSettings["UserName"];
            if (userName == null)
            {
                throw new ConfigurationErrorsException("No user configured!");
            }
            character = ConfigurationManager.AppSettings["Character"];
            if (character == null)
            {
                throw new ConfigurationErrorsException("No character configured!");
            }
            apiManager = new ApiManager();

            var kill = new ManualResetEvent(false);

            Console.CancelKeyPress += delegate { kill.Set(); };

            var compiler = new CSharpCodeProvider();
            var results  = compiler.CompileAssemblyFromFile(compilerParameters, ConfigurationManager.AppSettings["Script"]);
            var errors   = results.Errors.Cast <CompilerError>().ToList();

            if (errors.Count > 0)
            {
                foreach (var error in errors)
                {
                    Console.WriteLine(error.ErrorText);
                }
            }
            else
            {
                script = results.CompiledAssembly.ExportedTypes.Single();
                Connect();
            }

            kill.WaitOne();
        }
Esempio n. 5
0
 /// <summary>
 /// Factory Initializer
 /// </summary>
 public static void Link()
 {
     WebSocketFactory.Init(() => new WebsocketConnection());
 }
Esempio n. 6
0
 protected override IMvxApplication CreateApp()
 {
     AppDomain.CurrentDomain.UnhandledException += HandleException;
     WebSocketFactory.Init(() => new WebSocketConnection());
     return(new ViewModels.App());
 }