当前位置: 首页>>代码示例>>C#>>正文


C# Client.Start方法代码示例

本文整理汇总了C#中Client.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Client.Start方法的具体用法?C# Client.Start怎么用?C# Client.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client的用法示例。


在下文中一共展示了Client.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestClientRestarting

        public void TestClientRestarting()
        {
            Client client = new Client();
            client.Start();
            client.Stop();
            client.ToString();  // shouldn't throw an exception
            client.Start();
            client.Stop();

            client.Dispose();
            client.ToString();
        }
开发者ID:briandealwis,项目名称:gt,代码行数:12,代码来源:Lifecycle.cs

示例2: Main

        static void Main(string[] args)
        {
            var rand = new Random();

            var paramsProvider = new AppConfigProvider(ConfigurationManager.AppSettings);
            var configProvider = new ConfigurationProvider();
            var configFactory = new ConfigurationFactory(new ClientParams(paramsProvider), configProvider);

            var clientConfig = configFactory.Create<ClientConfiguration>();
            clientConfig.Port = rand.Next()%1000 + 25000;

            LogManager.Debug("Address is : 127.0.0.1:{0}", clientConfig.Port);

            var client = new Client(clientConfig);

            client.Start(Console.ReadLine(), () =>
            {
                var small = SmallTestObject.Create();
                while (true)
                {
                    var key = Console.ReadKey();
                    if (key.Key == ConsoleKey.Enter)
                        break;

                    small.Message = key.KeyChar.ToString();
                    client.SendObject(small);
                }
            });
        }
开发者ID:AlexNav73,项目名称:Tanks2DOnline,代码行数:29,代码来源:Program.cs

示例3: ClienteGT

        public ClienteGT(string host, string port)
        {
            // this.form = f;

            // Set up GT
            client = new Client(new DefaultClientConfiguration());
            client.ErrorEvent += es => Console.WriteLine(es);
            // client.ErrorEvent += es => MessageBox.Show(es.ToString());

            // Evento do client
            client.ConnexionRemoved += client_ConnexionRemoved;
            client.Start();

            // Evento do client
            client.MessageSent += new MessageHandler(this.MensagemEnviada);

            // updates: controle de acesso à sessão
            updates = client.OpenSessionChannel(host, port, SessionUpdatesChannelId, ChannelDeliveryRequirements.SessionLike);

            // Evento do updates
            updates.MessagesReceived += updates_SessionMessagesReceived;

            // Utilizar o OpenObjectChannel para enviar objetos genéricos
            objts = client.OpenObjectChannel(host, port, ObjectChannelId, ChannelDeliveryRequirements.CommandsLike);

            objts.MessagesReceived += new Action<IObjectChannel>(objts_MessagesReceived);
        }
开发者ID:pichiliani,项目名称:CoMusic,代码行数:27,代码来源:ClienteGT.cs

示例4: Main

 static void Main(string[] args)
 {
     Trace.Listeners.Add(new ConsoleTraceListener());
     System.Threading.Thread.Sleep(2000);
     using (Client client = new Client(4096))
     {
         IPEndPoint endPoint = new IPEndPoint(IPAddress.Loopback, 1337);
         client.Initialize();
         client.Start(endPoint);
         System.Console.ReadKey();
     }
 }
开发者ID:Daimakaicho,项目名称:TSIO,代码行数:12,代码来源:Program.cs

示例5: AntManager

 public AntManager(AntLoader loader)
 {
     _queenAnt = new Client(
         Properties.CreateProperties(
         loader.GetQueenIPEndPoint(),
         new ChannelPipe().SetCreateChannelAction(channel =>
         {
             channel.SetConfig("encoder", BsonEncoder.Encoder);
             channel.SetConfig("decoder", BsonDecoder.Decoder);
             channel.SetConfig("handler", this);
         })));
     _queenAnt.Start();
 }
开发者ID:growingdever,项目名称:Netronics,代码行数:13,代码来源:AntManager.cs

示例6: ClientTest

        public void ClientTest()
        {
            Console.WriteLine("Client 모듈 테스트 시작");
            var netronics = CreateNetronics();

            var client = new Client(Properties.CreateProperties(new IPEndPoint(IPAddress.Loopback, 17777), new ChannelPipe().SetCreateChannelAction(channel => { })));
            client.Start();
            System.Console.WriteLine("Client GetIPEndPoint" + client.GetEndIPPoint());

            client.Stop();
            netronics.Stop();
            Console.WriteLine("Client 모듈 테스트 완료");
        }
开发者ID:shlee322,项目名称:Netronics,代码行数:13,代码来源:NetronicsTest.cs

示例7: QueenPacketHandler

        private QueenPacketHandler()
        {
            _instance = this;

            _netronics = new Client(
                Properties.CreateProperties(
                Kernel.GetKernel().GetQueenIPEndPoint(),
                new ChannelPipe().SetCreateChannelAction(channel =>
                {
                    channel.SetConfig("encoder", BsonEncoder.Encoder);
                    channel.SetConfig("decoder", BsonDecoder.Decoder);
                    channel.SetConfig("handler", this);
                })));
            _netronics.Start();
        }
开发者ID:shlee322,项目名称:Netronics,代码行数:15,代码来源:QueenPacketHandler.cs

示例8: StartZetbox

        private void StartZetbox(object state)
        {
            try
            {
                Zetbox.API.APIInit init = new Zetbox.API.APIInit();
                init.Init();

                client = new Client();
                client.Start();

                ZetboxStarted = true;
            }
            catch
            {
                // Pech gehabt
            }
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:17,代码来源:App.xaml.cs

示例9: Form1

        public Form1()
        {
            InputDialog d = new InputDialog("Connection details", "Which server:port ?", "localhost:9999");
            if (d.ShowDialog() != DialogResult.OK)
            {
                throw new InvalidOperationException();
            }
            string[] parts = d.Input.Split(':');
            string host = parts[0];
            string port = parts.Length > 1 ? parts[1] : "9999";

            client = new Client();
            client.ConnexionRemoved += client_ConnexionRemoved;
            client.Start();
            chats = client.OpenStringChannel(host, port, ChatMessagesChannelId, ChannelDeliveryRequirements.ChatLike);
            updates = client.OpenSessionChannel(host, port, SessionUpdatesChannelId, ChannelDeliveryRequirements.SessionLike);
            InitializeComponent();
            this.Disposed += Form1_Disposed;
        }
开发者ID:pichiliani,项目名称:CoMusic,代码行数:19,代码来源:Form1.cs

示例10: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            InputDialog d = new InputDialog("Connection details", "Which server:port ?", "localhost:9999");
            if (d.ShowDialog() != DialogResult.OK)
            {
                throw new InvalidOperationException();
            }
            string[] parts = d.Input.Split(':');
            string host = parts[0];
            string port = parts.Length > 1 ? parts[1] : "9999";

            // Set up GT
            client = new Client(new DefaultClientConfiguration());
            client.ErrorEvent += es => Console.WriteLine(es);
            client.ConnexionRemoved += client_ConnexionRemoved;
            client.Start();

            updates = client.OpenSessionChannel(host, port, SessionUpdatesChannelId,
                ChannelDeliveryRequirements.SessionLike);
            updates.MessagesReceived += updates_SessionMessagesReceived;

            coords = client.OpenStreamedTuple<int, int>(host, port, TelepointersChannelId,
                TimeSpan.FromMilliseconds(50),
                ChannelDeliveryRequirements.AwarenessLike);
            coords.StreamedTupleReceived += coords_StreamedTupleReceived;
        }
开发者ID:briandealwis,项目名称:gt,代码行数:26,代码来源:Form1.cs

示例11: AcceptClient

        private void AcceptClient()
        {
            TcpClient tcp = Tcp.AcceptTcpClient();
            if (OnBeforeAccept(tcp))
            {
                Client c = new Client(this, AllocateEntity(), tcp);
                //Event
                ClientAcceptedEventArgs e = new ClientAcceptedEventArgs(this, c);
                PluginManager.CallEvent(Event.SERVER_ACCEPT, e);
                //Do not check for EventCanceled because that could make this unstable.
                //End Event

                lock (Clients)
                    Clients.Add(c.EntityId, c);
                AddEntity(c);
                c.Start();
                OnJoined(c);
            }
            else
            {
                tcp.Close();
            }
        }
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:23,代码来源:Server.cs

示例12: Run

        public void Run(string[] args)
        {
            List<Client> clients = new List<Client>();

            for (int i = 0; i < CLIENT_COUNT; i++)
            {
                Client c = new Client(("SRTClient:" + i), tlsKey, password, subject);
                c.Start();
                clients.Add(c);
            }

            Thread t = new Thread(() =>
            {
                while (true)
                {
                    Thread.Sleep(10000);

                    int badClientCount = 0;

                    for (int i = 0; i < clients.Count; i++)
                    {
                        if (clients[i].Reconnected == false)
                        {
                            Console.WriteLine("{0:HH:mm:ss} Client {1} may be locked with {2} missed attempts.",
                                        DateTime.Now, clients[i].clientName, clients[i].CurrentMissedReconnects);
                            badClientCount++;
                        }
                        clients[i].Reconnected = false;
                    }

                    Console.WriteLine("{0:HH:mm:ss} {1} clients checked, {2} are unhealthy.",
                        DateTime.Now, clients.Count, badClientCount);
                }
            });
            t.Name = "HealthChecker";
            t.Start();
        }
开发者ID:nats-io,项目名称:csnats,代码行数:37,代码来源:ReconnectTest.cs

示例13: StartClient

    internal static bool StartClient(IPEndPoint endPoint)
    {
      if (_client != null)
        return false;

      ClientMessageSink sink = ReceivedMessage;

      _client = new Client(endPoint, sink);
      _client.CommsFailureCallback = CommsFailure;
      _client.ConnectCallback = Connected;
      _client.DisconnectCallback = Disconnected;

      if (_client.Start())
      {
        return true;
      }
      else
      {
        _client = null;
        return false;
      }
    }
开发者ID:astalavister,项目名称:IR-Server-Suite,代码行数:22,代码来源:Program.cs

示例14: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            InputDialog d = new InputDialog("Connection details", "Which server:port ?", "localhost:9999");
            if (d.ShowDialog() != DialogResult.OK)
            {
                throw new InvalidOperationException();
            }
            string[] parts = d.Input.Split(':');
            string host = parts[0];
            string port = parts.Length > 1 ? parts[1] : "9999";

            // Aqui vou colocar a chamada para o cliente GT!
            // cGT = new ClienteGT(host, port);

            // Set up GT
            client = new Client(new DefaultClientConfiguration());
            client.ErrorEvent += es => Console.WriteLine(es);

            // Evento do client
            client.ConnexionRemoved += client_ConnexionRemoved;
            client.Start();

            // Evento do client
            client.MessageSent += new MessageHandler(this.MensagemEnviada);

            updates = client.OpenSessionChannel(host, port, SessionUpdatesChannelId,
                ChannelDeliveryRequirements.SessionLike);

            // Evento do updates
            updates.MessagesReceived += updates_SessionMessagesReceived;

            // coords armazena os dados recebidos (é a tupla)
               // coords = client.OpenStreamedTuple<int, int>(host, port, TelepointersChannelId,
               //     TimeSpan.FromMilliseconds(50),
               //     ChannelDeliveryRequirements.AwarenessLike);

            coords = client.OpenStreamedTuple<int, int>(host, port, TelepointersChannelId,
                TimeSpan.FromMilliseconds(50),
                ChannelDeliveryRequirements.AwarenessLike);

            // Evento do coords
            coords.StreamedTupleReceived += coords_StreamedTupleReceived;

            // coords.Identity

            // Utilizar o OpenObjectChannel para enviar um objeto ao invés de enviar uma tupla
            // objts = client.OpenObjectChannel(host, port, ObjectChannelId, ChannelDeliveryRequirements.AwarenessLike);
            objts = client.OpenObjectChannel(host, port, ObjectChannelId, ChannelDeliveryRequirements.CommandsLike);

            objts.MessagesReceived += new Action<IObjectChannel>(objts_MessagesReceived);
        }
开发者ID:pichiliani,项目名称:CoMusic,代码行数:51,代码来源:Form1.cs

示例15: Accept_Process

        private void Accept_Process(SocketAsyncEventArgs e)
        {
            if (OnBeforeAccept(e.AcceptSocket))
            {
                Client c = new Client(e.AcceptSocket, new Player(this, AllocateEntity()));
                //Event
                ClientAcceptedEventArgs args = new ClientAcceptedEventArgs(this, c);
                PluginManager.CallEvent(Event.SERVER_ACCEPT, args);
                //Do not check for EventCanceled because that could make this unstable.
                //End Event

                lock (Clients)
                {
                    AddClient(c);
                    Logger.Log(Chraft.Logger.LogLevel.Info, "Clients online: {0}", Clients.Count);
                }
                AddEntity(c.Owner);
                c.Start();
                Logger.Log(Chraft.Logger.LogLevel.Info, "Starting client");
                OnJoined(c);
            }
            else
            {
                e.AcceptSocket.Close();
            }

            Interlocked.Exchange(ref _AsyncAccepts, 0);
            NetworkSignal.Set();
        }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:29,代码来源:Server.cs


注:本文中的Client.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。