本文整理汇总了C#中EndPoint.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# EndPoint.ToString方法的具体用法?C# EndPoint.ToString怎么用?C# EndPoint.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EndPoint
的用法示例。
在下文中一共展示了EndPoint.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartClient
public bool StartClient()
{
// start the server
System.Diagnostics.Process wiiServer = new System.Diagnostics.Process();
wiiServer.StartInfo.FileName = "Assets\\WiimoteServer.exe";
// wiiServer.StartInfo.UseShellExecute = false;
wiiServer.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
wiiServer.Start();
//yield WaitForSeconds(5);
System.Threading.Thread.Sleep(4000);
// Servers ip (localhost) and port
ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050);
// Create a new udp socket on client side
serverSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
// Setup local reference for Server
remote = (EndPoint)ipep;
// Establish connection. Sending first message in bytes to serverSocket
string msg = "Hello, are you there?";
serverSocket.SendTo(Encoding.ASCII.GetBytes(msg), remote);
// Get response from serverSocket
String response = WaitForMsg();
String[] msgParts = response.Split(' ');
if (msgParts[0].Equals(acceptConnMsg))
{
Console.WriteLine("Connected to serverSocket at: " + remote.ToString());
numWiimotes = int.Parse(msgParts[1]);
wiiStates = new ClientWiiState[numWiimotes];
for (int i = 0; i < numWiimotes; i++)
wiiStates[i] = new ClientWiiState();
}
else
{
Console.WriteLine("Server refused connection. Most likely because no wiimotes exist");
return false;
}
return true;
}
示例2: GetPackage
public override void GetPackage (EndPoint remoteEP,short id, byte[] data)
{
Debug.Log("客户:"+ remoteEP.ToString() +"\n包ID:"+id+"\n包长度:"+data.Length);
}
示例3: Connection_Received
private void Connection_Received(EndPoint ep, TypedPackage package)
{
// Select player
if (!_players.ContainsKey(ep))
{
Debug.Log("Received UDP from unconnected client! By " + ep.ToString());
return;
}
SpawnedPlayer p = _players[ep];
// Handle msg
if (package.Type == PackageType.PlayerMove)
{
p.Positioning.FromBytes(package.Data, ref package.Offset);
p.Updated = true;
}
else if (package.Type == PackageType.PlayerShoot)
{
ShootingData message = new ShootingData(package.Data, ref package.Offset);
p.ShootBuffer.Shots.AddRange(message.Shots);
}
else if (package.Type == PackageType.BoatPartHit)
{
HealthData message = new HealthData(package.Data, ref package.Offset);
lock (p.HitBuffer)
p.HitBuffer.Add(message);
}
else
{
Debug.Log("Unhandled UDP msg");
}
}