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


C# Network.NetClient类代码示例

本文整理汇总了C#中Lidgren.Network.NetClient的典型用法代码示例。如果您正苦于以下问题:C# NetClient类的具体用法?C# NetClient怎么用?C# NetClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: NetClientHelper

 public NetClientHelper()
 {
     NetPeerConfiguration config = new NetPeerConfiguration("CozyKxlol");
     config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
     client = new NetClient(config);
     client.Start();
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:7,代码来源:NetClientHelper.cs

示例2: MPClient

 /// <summary>
 /// MPCLient constructor with MPThreadStopCondition as a parameter.
 /// </summary>
 /// <param name="condition">The condition to stop the ProcessMessageThread.</param>
 public MPClient(MPSharedCondition condition)
 {
     StopMessageProcessingThread = condition ?? new MPSharedCondition(false);
     ResetConfig();
     netClient = new NetClient(config);
     pts = new ParameterizedThreadStart(this.ProcessMessage);
 }
开发者ID:rockhowse,项目名称:Gurkenplayer,代码行数:11,代码来源:MPClient.cs

示例3: Client

        public Client(RenderWindow window, ImageManager imageManager)
            : base(window, imageManager)
        {
            this.window = window;
            world = new RenderImage(800, 600);

            inputManager = new InputManager(this);

            ticker = new Ticker();

            window.ShowMouseCursor (false);
            window.SetFramerateLimit (60);

            NetPeerConfiguration netConfiguration = new NetPeerConfiguration("2dThing");
            client = new NetClient(netConfiguration);

            uMsgBuffer = new UserMessageBuffer();
            otherClients = new Dictionary<int, NetworkClient>();
            chat = new Chat(this);

            LoadRessources();

            blockTypeDisplay = new Cube(blockType, imageManager);
            blockTypeDisplay.Position = new Vector2f(window.Width - 2*Cube.WIDTH, window.Height - 2* Cube.HEIGHT);
            layerDisplay = new LayerDisplay(imageManager);
            layerDisplay.Position = blockTypeDisplay.Position - new Vector2f(0, 50);

            mouse = new Sprite (imageManager.GetImage("mouse"));
        }
开发者ID:CyrilPaulus,项目名称:2dThing,代码行数:29,代码来源:Client.cs

示例4: Connect

        public static void Connect(IPEndPoint endpoint, MMDevice device, ICodec codec)
        {
            var config = new NetPeerConfiguration("airgap");

            _client = new NetClient(config);
            _client.RegisterReceivedCallback(MessageReceived);

            _client.Start();

            _waveIn = new WasapiLoopbackCapture(device);
            _codec = codec;

            _sourceFormat = _waveIn.WaveFormat;
            _targetFormat = new WaveFormat(_codec.SampleRate, _codec.Channels); // format to convert to

            _waveIn.DataAvailable += SendData;
            _waveIn.RecordingStopped += (sender, args) => Console.WriteLine("Stopped");
            // TODO: RecordingStopped is called when you change the audio device settings, should recover from that

            NetOutgoingMessage formatMsg = _client.CreateMessage();
            formatMsg.Write(_targetFormat.Channels);
            formatMsg.Write(_targetFormat.SampleRate);
            formatMsg.Write(codec.Name);

            _client.Connect(endpoint, formatMsg);
        }
开发者ID:JamieH,项目名称:AudioGap,代码行数:26,代码来源:Network.cs

示例5: SpaceClient

        public SpaceClient()
        {
            config = Constants.GetConfig();
            client = new NetClient(config);

            ClientStarted = false;
        }
开发者ID:FingerInSky,项目名称:SpaceCrush,代码行数:7,代码来源:SpaceClient.cs

示例6: fireConnectionRejected

 public void fireConnectionRejected(NetClient client, NetBuffer buffer)
 {
     if (ConnectionRejected != null)
     {
         ConnectionRejected(client, buffer);
     }
 }
开发者ID:rcrowe,项目名称:ees_xplane,代码行数:7,代码来源:NetworkEvents.cs

示例7: Connect

        public void Connect()
        {
            client = new NetClient(config);
            client.Start();

            client.DiscoverLocalPeers(14242);
        }
开发者ID:BenMatase,项目名称:RaginRovers,代码行数:7,代码来源:ClientNetworking.cs

示例8: NetworkManager

 private NetworkManager()
 {
     NetPeerConfiguration config = new NetPeerConfiguration("SpireServer");
     config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
     config.NetworkThreadName = "Spire Client";
     client = new NetClient(config);
 }
开发者ID:poemdexter,项目名称:Spire-Venture,代码行数:7,代码来源:NetworkManager.cs

示例9: SetUpConnection

        public void SetUpConnection()
        {
            configuration = new NetPeerConfiguration("PingPong");

            configuration.EnableMessageType(NetIncomingMessageType.WarningMessage);
            configuration.EnableMessageType(NetIncomingMessageType.VerboseDebugMessage);
            configuration.EnableMessageType(NetIncomingMessageType.ErrorMessage);
            configuration.EnableMessageType(NetIncomingMessageType.Error);
            configuration.EnableMessageType(NetIncomingMessageType.DebugMessage);
            configuration.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
            configuration.EnableMessageType(NetIncomingMessageType.Data);

            switch (networkRole)
            {
                case GamerNetworkType.Client:
                    Client = new NetClient(configuration);
                    Client.Start();
                    Client.Connect(new IPEndPoint(NetUtility.Resolve(IP), Convert.ToInt32(Port)));
                    break;
                case GamerNetworkType.Server:
                    configuration.Port = Convert.ToInt32(Port);
                    Server = new NetServer(configuration);
                    Server.Start();
                    break;
                default:
                    throw new ArgumentException("Network type was not set");
            }
        }
开发者ID:ICanHaz,项目名称:Super-Ping-Pong,代码行数:28,代码来源:NetworkManager.cs

示例10: SetupClient

 private void SetupClient()
 {
     NetPeerConfiguration config = new NetPeerConfiguration("dystopia");
     Client = new NetClient(config);
     Client.Start();
     Client.Connect(NetUtility.Resolve(ServerIP, ServerPort));
 }
开发者ID:Tricon2-Elf,项目名称:DystopiaRPG,代码行数:7,代码来源:GameplayScreen.cs

示例11: Client_Load

        private void Client_Load(object sender, EventArgs e)
        {
            NetPeerConfiguration config = new NetPeerConfiguration("Testing");
            config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);

            client = new NetClient(config);
        }
开发者ID:DV8FromTheWorld,项目名称:C-Sharp-Programming,代码行数:7,代码来源:Client.cs

示例12: ConnectServer

 private static NetClient ConnectServer()
 {
     var config = new NetPeerConfiguration("pic") {EnableUPnP = true};
     var thisClient = new NetClient(config);
     thisClient.RegisterReceivedCallback(HandleMessage);
     return thisClient;
 }
开发者ID:JamieH,项目名称:Pictionary,代码行数:7,代码来源:Network.cs

示例13: InitClients

        public void InitClients(int netClientcount)
        {
            m_NetClientCount = netClientcount;
            Nets = new NetClient[m_NetClientCount];
            TextNetMsgS = new string[m_NetClientCount];
            m_lastSent = new double[m_NetClientCount];
            TextNetMsgSB = new StringBuilder();
            System.Net.IPAddress mask = null;
            System.Net.IPAddress local = NetUtility.GetMyAddress(out mask);
            //
            for (int i = 0; i < Nets.Length; i++) {
                NetPeerConfiguration config = new NetPeerConfiguration("many");

                config.LocalAddress = local;
            #if DEBUG
            config.SimulatedLoss = 0.02f;
            #endif
                NetClient Net = new NetClient(config);
                Nets[i] = Net;
                Net.Start();
                //Net.Connect("localhost", 14242);
                Net.Connect(new System.Net.IPEndPoint(config.LocalAddress, 14242));
                //
                Application.DoEvents();
            }
        }
开发者ID:RainsSoft,项目名称:lidgren-network-gen3,代码行数:26,代码来源:Client.cs

示例14: StartDiscoveryInternal

		/// <summary>
		/// 
		/// </summary>
		/// <param name="numPorts"></param>
		/// <param name="timeout"></param>
		void StartDiscoveryInternal ( int numPorts, TimeSpan timeout )
		{
			lock (lockObj) {
				if (client!=null) {
					Log.Warning("Discovery is already started.");
					return;
				}

				this.timeout	=	timeout;

				var netConfig = new NetPeerConfiguration( Game.GameID );
				netConfig.EnableMessageType( NetIncomingMessageType.DiscoveryRequest );
				netConfig.EnableMessageType( NetIncomingMessageType.DiscoveryResponse );

				client	=	new NetClient( netConfig );
				client.Start();

				var svPort	=	Game.Network.Port;

				var ports = Enumerable.Range(svPort, numPorts)
							.Where( p => p <= ushort.MaxValue )
							.ToArray();

				Log.Message("Start discovery on ports: {0}", string.Join(", ", ports) );

				foreach (var port in ports) {
					client.DiscoverLocalPeers( port );
				}
			}
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:35,代码来源:UserInterface.Internal.cs

示例15: SendUpdates

 public void SendUpdates(NetClient client)
 {
     NetOutgoingMessage om = client.CreateMessage();
     om.Write(Helpers.TransferType.ProjectileUpdate);
     om.Write(new ProjectileTransferableData(client.UniqueIdentifier,ID,IsValid,Position,Angle));
     client.SendMessage(om, NetDeliveryMethod.UnreliableSequenced);
 }
开发者ID:elefantstudio-se,项目名称:xna-lidgren-multiplayer-game,代码行数:7,代码来源:ProjectileLocal.cs


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