예제 #1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ServerName.Length != 0)
            {
                hash ^= ServerName.GetHashCode();
            }
            if (ServerAddr.Length != 0)
            {
                hash ^= ServerAddr.GetHashCode();
            }
            if (ServerPort != 0)
            {
                hash ^= ServerPort.GetHashCode();
            }
            if (ServerState != 0)
            {
                hash ^= ServerState.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
예제 #2
0
 private void ServerPort_Leave(object sender, EventArgs e)
 {
     if (!IsPortValid())
     {
         ServerPort.Focus();
     }
 }
예제 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("启动服务器...");
            //コンソールにログを表示させる
            GrpcEnvironment.SetLogger(new Grpc.Core.Logging.ConsoleLogger());

            var service = MagicOnionEngine.BuildServerServiceDefinition(isReturnExceptionStackTraceInErrorDetail: true);

            var serverPort = new ServerPort("localhost", 12345, ServerCredentials.Insecure);

            // localhost:12345でListen
            var server = new Server
            {
                Services = { service },
                Ports    = { serverPort }
            };

            // MagicOnion起動
            server.Start();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine($"启动完成... {serverPort.Host}:{serverPort.Port}");
            Console.ForegroundColor = ConsoleColor.White;

            // コンソールアプリが落ちないようにReadLineで待つ
            Console.ReadLine();
        }
예제 #4
0
        protected override void CreateAndStartService()
        {
            base.CreateAndStartService();

            var conPort = new ServerPort("127.0.0.1", ServerPort.PickUnused, ServerCredentials.Insecure);

            var server = new Server
            {
                Services = { VRWorlds.Schemas.Browser.Common.Ping.BindService(new PingImpl(ProcessId)) },
                Ports    = { conPort, }
            };

            // I don't think we're running in our service thread here -- have to start farther down
            server.Start();

            var bound = -1;

            foreach (var p in server.Ports)
            {
                if (p.BoundPort > 0)
                {
                    bound = p.BoundPort;
                }
                //  Debug.Log("Port: " + p.Port.ToString() + ", bound: "+p.BoundPort.ToString());
            }

            var host = conPort.Host + ":" + bound.ToString();

            Debug.Log("Binding to: " + host);
            GrpcIngressUri = host;
        }
예제 #5
0
        static async Task Main(string[] _)
        {
            //gRPCサーバーのAddress・Port設定
            var serverPort = new ServerPort("localhost", 1234, ServerCredentials.Insecure);

            //ロガーとかの設定
            var magicOnionOptions = new MagicOnionOptions(isReturnExceptionStackTraceInErrorDetail: true)
            {
                //todo:settings
            };

            //サービスクラスの実装が別アセンブリの場合はアセンブリを指定する
            var searchAssembly = new[] { typeof(Sample.MagicOnion.Server.Calculator).Assembly };

            //MagicOnion.Hostingを使用する場合
            {
                await MagicOnionHost.CreateDefaultBuilder()
                .UseMagicOnion(searchAssembly, magicOnionOptions, serverPort)
                .RunConsoleAsync();
            }

            //自前でgRPC.Core.Serverを実行する場合
            {
                var server = new Grpc.Core.Server()
                {
                    Ports    = { serverPort },
                    Services = { MagicOnionEngine.BuildServerServiceDefinition(searchAssembly, magicOnionOptions) }
                };

                server.Start();

                Console.ReadLine();
            }
        }
 /// <summary>
 /// Dispose the serverPort.
 /// </summary>
 /// <param name="serverPort"></param>
 private void DisposeServerPort(ServerPort serverPort)
 {
     if (!DisposableRpcObjects)
     {
         return;
     }
 }
예제 #7
0
 private void OptionsDialog_Load(object sender, EventArgs e)
 {
     _textBoxServerAE.Text   = ServerAE;
     _textBoxServerIP.Text   = ServerIP;
     _textBoxServerPort.Text = ServerPort.ToString();
     _textBoxTimeout.Text    = Timeout.ToString();
 }
예제 #8
0
 /// <summary>add MagicOnion service to generic host from all assemblies.</summary>
 public static IHostBuilder UseMagicOnion(this IHostBuilder hostBuilder,
                                          ServerPort ports,
                                          MagicOnionOptions options,
                                          IEnumerable <ChannelOption> channelOptions = null)
 {
     return(UseMagicOnion(hostBuilder, new[] { ports }, options, channelOptions: channelOptions));
 }
예제 #9
0
    protected override void StartOnlyOneTime()
    {
        sp = GameCore.Instance.Get <ServerPort>();
        sp.OnMessage("Message", OnMessage);

        Room4Client.OnBattleBegin += OnBattleBegin;
    }
        private void ConnectOnprem()
        {
            AuthType = AuthenticationProviderType.ActiveDirectory;

            NetworkCredential credential;

            if (!IsCustomAuth)
            {
                credential = CredentialCache.DefaultNetworkCredentials;
            }
            else
            {
                var password = CryptoManager.Decrypt(userPassword, ConnectionManager.CryptoPassPhrase,
                                                     ConnectionManager.CryptoSaltValue,
                                                     ConnectionManager.CryptoHashAlgorythm,
                                                     ConnectionManager.CryptoPasswordIterations,
                                                     ConnectionManager.CryptoInitVector,
                                                     ConnectionManager.CryptoKeySize);

                credential = new NetworkCredential(UserName, password, UserDomain);
            }

            crmSvc = new CrmServiceClient(credential,
                                          AuthenticationType.AD,
                                          ServerName,
                                          ServerPort.ToString(),
                                          OrganizationUrlName,
                                          true,
                                          UseSsl);
        }
예제 #11
0
        public static void Main(string[] args)
        {
            DotNetEnv.Env.Load();

            var kafkaConfig = new ProducerConfig {
                BootstrapServers = DotNetEnv.Env.GetString("KAFKA_PRODUCER_HOST")
            };
            var producer = new ProducerBuilder <Null, string>(kafkaConfig).Build();
            var smartCom = new StServerClass();
            var logger   = new ConsoleLogger();

            ServerEventsListener listener = new ServerEventsListener(smartCom, producer, logger);

            listener.Start();

            smartCom.connect(
                DotNetEnv.Env.GetString("SMARTCOM_SERVER_HOST"),
                (ushort)DotNetEnv.Env.GetDouble("SMARTCOM_SERVER_PORT"),
                DotNetEnv.Env.GetString("SMARTCOM_SERVER_LOGIN"),
                DotNetEnv.Env.GetString("SMARTCOM_SERVER_PASSWORD")
                );

            var gRpcPort = new ServerPort(
                "",
                DotNetEnv.Env.GetInt("GRPC_PORT"),
                ServerCredentials.Insecure
                );

            var brokerService = new BrokerService(smartCom, logger);

            Server server = new Server
            {
                Services = { ITICapitalAPI.BindService(brokerService) },
                Ports    = { gRpcPort }
            };

            server.Start();

            logger.Write($"Start gRPC on {gRpcPort.Host}:{gRpcPort.Port}");
            logger.Write($"Listen kafka on {kafkaConfig.BootstrapServers}");

            var isStopped = false;

            AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) =>
            {
                isStopped = true;
                logger.Write("Stop signal");
            };

            while (!isStopped)
            {
            }

            logger.Write("Stopping gRPC and SmartCOM...");

            smartCom.disconnect();
            server.ShutdownAsync().Wait();

            logger.Write("Stopped");
        }
        private void ConnectIfd()
        {
            AuthType = AuthenticationProviderType.Federation;

            if (!IsCustomAuth)
            {
                crmSvc = new CrmServiceClient(CredentialCache.DefaultNetworkCredentials,
                                              AuthenticationType.IFD,
                                              ServerName,
                                              ServerPort.ToString(),
                                              OrganizationUrlName,
                                              true,
                                              UseSsl);
            }
            else
            {
                var password = CryptoManager.Decrypt(userPassword, ConnectionManager.CryptoPassPhrase,
                                                     ConnectionManager.CryptoSaltValue,
                                                     ConnectionManager.CryptoHashAlgorythm,
                                                     ConnectionManager.CryptoPasswordIterations,
                                                     ConnectionManager.CryptoInitVector,
                                                     ConnectionManager.CryptoKeySize);

                crmSvc = new CrmServiceClient(UserName, CrmServiceClient.MakeSecureString(password), UserDomain,
                                              HomeRealmUrl,
                                              ServerName,
                                              ServerPort.ToString(),
                                              OrganizationUrlName,
                                              true,
                                              UseSsl);
            }
        }
예제 #13
0
파일: Room4Client.cs 프로젝트: radtek/SCM2
    public void Init()
    {
        sp       = GameCore.Instance.Get <ServerPort>();
        replayer = new BattleReplayer();
        GameCore.Instance.Add("Replayer", replayer);
        GameCore.Instance.Room = this;

        OnMessageDirectly("BattleBegin", OnBattleBeginMsg);
        OnMessageDirectly("FF", OnFrameMoveForwardMsg);
        OnMessageDirectly("BattleEnd", OnBattleEndMsg);

        // BufferMessage("SetPath", OnSetPathMsg);
        BufferMessage("CosntructBuildingUnit", OnCosntructBuildingUnitMsg);
        BufferMessage("ConstructCrystalMachine", OnConstructCrystalMachineMsg);
        BufferMessage("ConstructAccessory", OnConstructAccessoryMsg);
        BufferMessage("ReconstructBuilding", OnRecosntructBuildingMsg);
        BufferMessage("CancelBuilding", OnCancelBuildingMsg);
        BufferMessage("DestroyBuilding", OnDestroyBuildingMsg);
        BufferMessage("CheatCode", OnCheatCodeMsg);
        BufferMessage("DropSoldierFromCarrier", OnDropSoldierFromCarrierMsg);
        BufferMessage("AddUnitAt", OnAddUnitAtMsg);
        BufferMessage("PlayerSwitched", OnPlayersSwitchedMsg);
        BufferMessage("AddBattleUnitAt", OnAddBattleUnitAtMsg);
        BufferMessage("AddBattleUnit4TestAnyway", OnAddBattleUnit4TestAnyway);
        BufferMessage("AddBuildingUnit4TestAnyway", OnAddBuildingUnit4TestAnyway);
        BufferMessage("AddSoldierCarrierUnit4TestAnyway", OnAddSoldierCarrierUnit4TestAnyway);
        BufferMessage("Crash", OnCrashMsg);
    }
예제 #14
0
        static void Main(string[] args)
        {
            //gRPCサーバーのAddress・Port設定
            var serverPort = new ServerPort("localhost", 1234, ServerCredentials.Insecure);

            //ロガーとかの設定
            var magicOnionOptions = new MagicOnionOptions(isReturnExceptionStackTraceInErrorDetail: true)
            {
                //todo:settings
            };

            //サービスクラスの実装が別アセンブリの場合はアセンブリを指定する
            var searchAssembly = new[] { typeof(Sample.MagicOnion.Server.Calculator).Assembly };


            var server = new Grpc.Core.Server()
            {
                Ports    = { serverPort },
                Services =
                {
                    //MagicOnionサービス
                    MagicOnionEngine.BuildServerServiceDefinition(searchAssembly,                             magicOnionOptions),

                    //PureGrpcサービス
                    PureGrpc.Definitions.Calculator.BindService(new Sample.PureGrpc.Server.CalculatorImpl()),
                    PureGrpc.Definitions.Health.BindService(new Sample.PureGrpc.Server.HealthImpl()),
                }
            };

            server.Start();

            Console.ReadLine();
        }
예제 #15
0
        public override string GetDefaultName()
        {
            string sPort = (ServerPort == DEFAULT_PGSQL_PORT) ? string.Empty : ":" + ServerPort.ToString();
            string sDb   = (DatabaseName == DEFAULT_PGSQL_DBNAME) ? string.Empty : "/" + DatabaseName;

            return(string.Format("{0}@{1}{2}{3}", UserName, ServerName, sPort, sDb));
        }
예제 #16
0
파일: PVPUI.cs 프로젝트: radtek/SCM2
    protected override void StartOnlyOneTime()
    {
        Room4Client.OnBattleBegin += OnBattleBegin;
        GameCore.Instance.OnMainConnectionDisconnected += OnMainConnectionDisconnected;

        sp = GameCore.Instance.Get <ServerPort>();
        sp.OnMessage("BattleReady", OnBattleReady);
    }
예제 #17
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType <GrpcHostedService>().As <IHostedService>().SingleInstance();

            var serverPort = new ServerPort(_configuration.GetValue <string>("IP"), _configuration.GetValue <int>("PORT"), ServerCredentials.Insecure);

            builder.RegisterInstance(serverPort).As <ServerPort>();
        }
예제 #18
0
파일: KPort.cs 프로젝트: zhubaojian/Ryujinx
        public void Initialize(int MaxSessions, bool IsLight, long NameAddress)
        {
            ServerPort.Initialize(this);
            ClientPort.Initialize(this, MaxSessions);

            this.IsLight     = IsLight;
            this.NameAddress = NameAddress;
        }
예제 #19
0
 private void ParameterSaveCommandExecute()
 {
     Inifile.INIWriteValue(iniParameterPath, "System", "WorkPath", WorkPath);
     Inifile.INIWriteValue(iniParameterPath, "System", "ImageSavePath", ImageSavePath);
     Inifile.INIWriteValue(iniParameterPath, "Server", "IP", ServerIP);
     Inifile.INIWriteValue(iniParameterPath, "Server", "PORT", ServerPort.ToString());
     AddMessage("保存参数");
 }
예제 #20
0
        public static ILifecycle Create(RpcEndPoint endPoint, IGameServerRegistrar gameServerRegistrar)
        {
            var port       = new ServerPort(endPoint.Host, endPoint.Port, ServerCredentials.Insecure);
            var controller = new RpcServiceController(port);

            controller.RegisterService(token => GameServerRegistrar.BindService(new GameServerRegistrarService(gameServerRegistrar, token)));
            return(controller);
        }
예제 #21
0
        public string GetConfigure()
        {
            string configInfo = "akka.tcp://" + ServerActorSystemName + "@" +
                                ServerIP + ":" + ServerPort.ToString() + "/user/" +
                                ServerRootActorName + "/" + ClientServerActorName;

            return(configInfo);
        }
예제 #22
0
        public static ILifecycle Create(RpcEndPoint endPoint, IAccountLoginService accountLoginService)
        {
            var port       = new ServerPort(endPoint.Host, endPoint.Port, ServerCredentials.Insecure);
            var controller = new RpcServiceController(port);

            controller.RegisterService(token => AccountAuthentication.BindService(new AccountAuthenticationService(accountLoginService, token)));
            return(controller);
        }
예제 #23
0
파일: KPort.cs 프로젝트: mokmax/Ryujinx
        public void Initialize(int maxSessions, bool isLight, long nameAddress)
        {
            ServerPort.Initialize(this);
            ClientPort.Initialize(this, maxSessions);

            _isLight     = isLight;
            _nameAddress = nameAddress;
        }
 public GrpcCommunicationListener(
     IEnumerable <Func <CancellationToken, ServerServiceDefinition> > services,
     ServiceContext serviceContext,
     string endpointName)
 {
     _services       = services ?? throw new ArgumentNullException(nameof(services));
     _serviceContext = serviceContext ?? throw new ArgumentNullException(nameof(serviceContext));
     _serverPort     = GetServerPort(endpointName);
 }
예제 #25
0
        public static async void TesteChannel()
        {
            Server server = new Server();

            var serverPort = new ServerPort("127.0.0.1", P_PORTA_RPC, ServerCredentials.Insecure);

            server.Ports.Add(serverPort);

            var searchService = SearchService.BindService(new MyService());

            server.Services.Add(searchService);
            server.Start();

            Channel channel = new Channel("localhost", P_PORTA_RPC, ChannelCredentials.Insecure);

            channel.ConnectAsync(DateTime.UtcNow.AddSeconds(4)).Wait();
            var client = new SearchServiceClient(channel);

            SearchRequest req = new SearchRequest();

            req.FileMask     = "*.bat";
            req.StartDir     = @"C:\";
            req.Recursive    = true;
            req.IgnoreErrors = true;
            var result = client.Search(req);

            Debug.WriteLine("[p1]");

            var t1 = client.Delay1Async(new DelayDesc()
            {
                MilliSeconds = 2000
            });

            Debug.WriteLine("[p2]");

            Debug.WriteLine("[p3]");

            var t2 = client.Delay2Async(new DelayDesc()
            {
                MilliSeconds = 1000
            });

            Debug.WriteLine("[p4]");

            Empty v1 = await t1;

            Debug.WriteLine("[p5]");

            Empty v2 = await t2;

            Debug.WriteLine("[p6]");

            ProcessStartInfoPB psi = new ProcessStartInfoPB();

            psi.FileName = "c:/temp/teste.bat";
            var p = client.RunCmd(psi);
        }
예제 #26
0
        public static void Save()
        {
            var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Reflect.WebServer.Data.ini");

            var fileIni = new IniFile(path);

            fileIni.Write("Port", ServerPort.ToString(), "Server");
            fileIni.Write("Root", ServerRoot, "Server");
        }
예제 #27
0
 public GrpcService(
     IPublisher publisher,
     string host,
     int port
     )
 {
     _publisher  = publisher;
     _serverPort = new ServerPort(host, port, ServerCredentials.Insecure);
 }
예제 #28
0
        // Method:      StartServer_Click()
        // Description: This method takes the port from the interface, validates it
        //              and once validated, it fire ups the server and send user to
        //              chat screen.
        private void StartServer_Click(object sender, EventArgs e)
        {
            // application is running server, update the variable to let other methods know
            ServerItIs = true;

            // get port from interface and clear the textbox
            string portString = ServerPort.Text;

            ServerPort.Clear();
            bool valid = false;


            // validate port
            int temp = 0;

            int.TryParse(portString, out temp);

            if (temp > 0)
            {
                valid = true;
            }

            // start server if port is valid
            if (valid)
            {
                Int32     port = Int32.Parse(portString);
                IPAddress ip   = IPAddress.Parse("127.0.0.1");

                try
                {
                    server = new TcpListener(ip, port);

                    // start server
                    server.Start();

                    // bring chat panel to front
                    ChatPanel.BringToFront();
                    TypeBox.Focus();

                    // update textbox at the top with IP address and port
                    ConnectionInfo.Text = "IP: " + GetLocalIPAddress() + "   Port: " + port;

                    // start thread to handle the client
                    ThreadPool.QueueUserWorkItem(HandleClient);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
            else
            {
                MessageBox.Show("Port cannot be alphabet, special character or negative number." +
                                "Please try again");
            }
        }
예제 #29
0
        public GrpcServerBuilder AddInsecurePort(int port, string host = null)
        {
            if (string.IsNullOrWhiteSpace(host))
            {
                host = "0.0.0.0";
            }

            _insecurePort = new ServerPort(host, port, ServerCredentials.Insecure);
            return(this);
        }
예제 #30
0
        public IGrpcServerBuilder <TRequest, TResponse> ConfigurePort(int port)
        {
            var serverPort = new ServerPort(
                IPAddress.Any.ToString(),
                port,
                _httpEnabled ? ServerCredentials.Insecure : null);

            _server.Ports.Add(serverPort);
            return(this);
        }