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


C# EndPoint.ToString方法代码示例

本文整理汇总了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;
    }
开发者ID:jstasiak,项目名称:r2d2_assignment,代码行数:48,代码来源:WiiUnityClient.cs

示例2: GetPackage

	public override void GetPackage (EndPoint remoteEP,short id, byte[] data)
	{
		Debug.Log("客户:"+ remoteEP.ToString() +"\n包ID:"+id+"\n包长度:"+data.Length);
	}
开发者ID:TowerSay,项目名称:Tower,代码行数:4,代码来源:P2PServer.cs

示例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");
        }
    }
开发者ID:florisdh,项目名称:LCPiratesOnline,代码行数:33,代码来源:ClientManager.cs


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