本文整理汇总了C#中Lidgren.Network.NetClient类的典型用法代码示例。如果您正苦于以下问题:C# NetClient类的具体用法?C# NetClient怎么用?C# NetClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetClient类属于Lidgren.Network命名空间,在下文中一共展示了NetClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Main
public static void Main(string[] args)
{
Console.WriteLine("[CLIENT] Testing Lidgren-Network-v3...");
NetPeerConfiguration clientConfig = new NetPeerConfiguration("test");
clientConfig.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
NetClient client = new NetClient(clientConfig);
client.Start();
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
client.RegisterReceivedCallback(new SendOrPostCallback(GotMessage));
Console.WriteLine("IP to connect to: ");
String ip = Console.ReadLine();
client.Connect(new System.Net.IPEndPoint(System.Net.IPAddress.Parse(ip), 12345));
while(true) {
string msg = Console.ReadLine();
NetOutgoingMessage sendMsg = client.CreateMessage();
sendMsg.Write("[CLIENT] " + msg);
client.SendMessage(sendMsg, NetDeliveryMethod.ReliableOrdered);
}
}
开发者ID:uwrov,项目名称:teaching,代码行数:25,代码来源:Client.cs
示例17: WorldClientBase
public WorldClientBase(string protocolVersion)
{
this.protocolVersion = protocolVersion;
// Net configuration
NetPeerConfiguration cfg = new NetPeerConfiguration("Asteria");
cfg.MaximumConnections = 1;
cfg.ReceiveBufferSize = 4095;
cfg.MaximumTransmissionUnit = 4095;
#if DEBUG
try
{
cfg.EnableMessageType(NetIncomingMessageType.VerboseDebugMessage);
}
catch
{
Logger.Output(this, "Running in debug mode but using release Lidgren library version, Lidgren debug messages disabled!");
}
#endif
client = new NetClient(cfg);
client.Start();
// Create objects needed.
sendingQ = new Queue<ClientToServerMessage>(64);
receivingQ = new Queue<NetIncomingMessage>(128);
newDataArrivedEvent = new AutoResetEvent(false);
messages = new Dictionary<MessageType, List<ServerToClientMessage>>();
serializer = new ClientToServerMessageSerializer();
deserializer = new ServerToClientMessageSerializer();
isRunning = true;
}
开发者ID:KtBkkr,项目名称:Asteria,代码行数:33,代码来源:WorldClientBase.cs
示例18: NetworkMultiplayer
public NetworkMultiplayer(bool createServer = false)
: base(GameModes.Network)
{
if(createServer)
GameServer = new GameServer();
//read network on each update
Game.Instance.OnUpdate += ReadNetwork;
//server config
NetPeerConfiguration config = new NetPeerConfiguration("tank");
config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
//server creation
Client = new NetClient(config);
Client.Start();
if (!createServer)
{
//check whether the user has a known server
ListMenu serverMenu = new ListMenu("Do you want to connect to a given IP (if yes, enter in console)?", "tank.Code.YESORNOCHOOSENOW", ConnectionMethodSelectionCallback);
Scene.Add(serverMenu);
}
else//we know that a local server must exist
Client.DiscoverLocalPeers(14242);
//register handler for receiving data
OnClientData += IncomingHandler;
//are we client, or are we dancer?
if(!createServer)
Console.WriteLine("client");
}
开发者ID:JOCP9733,项目名称:tank,代码行数:32,代码来源:NetworkMultiplayer.cs
示例19: fireDataRecieved
public void fireDataRecieved(NetClient client, NetBuffer buffer)
{
if (DataRecieved != null)
{
DataRecieved(client, buffer);
}
}
开发者ID:rcrowe,项目名称:ees_xplane,代码行数:7,代码来源:NetworkEvents.cs
示例20: Client
public Client()
{
NetPeerConfiguration config = new NetPeerConfiguration("CozyAnywhere");
config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
client = new NetClient(config);
client.RegisterReceivedCallback(RecivePacket);
}
开发者ID:shangshen,项目名称:cozy,代码行数:7,代码来源:ClientMain.cs
注:本文中的Lidgren.Network.NetClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论