本文整理汇总了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();
}
示例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);
}
示例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"));
}
示例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);
}
示例5: SpaceClient
public SpaceClient()
{
config = Constants.GetConfig();
client = new NetClient(config);
ClientStarted = false;
}
示例6: fireConnectionRejected
public void fireConnectionRejected(NetClient client, NetBuffer buffer)
{
if (ConnectionRejected != null)
{
ConnectionRejected(client, buffer);
}
}
示例7: Connect
public void Connect()
{
client = new NetClient(config);
client.Start();
client.DiscoverLocalPeers(14242);
}
示例8: NetworkManager
private NetworkManager()
{
NetPeerConfiguration config = new NetPeerConfiguration("SpireServer");
config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
config.NetworkThreadName = "Spire Client";
client = new NetClient(config);
}
示例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");
}
}
示例10: SetupClient
private void SetupClient()
{
NetPeerConfiguration config = new NetPeerConfiguration("dystopia");
Client = new NetClient(config);
Client.Start();
Client.Connect(NetUtility.Resolve(ServerIP, ServerPort));
}
示例11: Client_Load
private void Client_Load(object sender, EventArgs e)
{
NetPeerConfiguration config = new NetPeerConfiguration("Testing");
config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
client = new NetClient(config);
}
示例12: ConnectServer
private static NetClient ConnectServer()
{
var config = new NetPeerConfiguration("pic") {EnableUPnP = true};
var thisClient = new NetClient(config);
thisClient.RegisterReceivedCallback(HandleMessage);
return thisClient;
}
示例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();
}
}
示例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 );
}
}
}
示例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);
}