UnityEngine.Networking.NetworkDiscovery.BytesToString C# (CSharp) Method

BytesToString() private static method

private static BytesToString ( byte bytes ) : string
bytes byte
return string
        private static string BytesToString(byte[] bytes)
        {
            char[] dst = new char[bytes.Length / 2];
            Buffer.BlockCopy(bytes, 0, dst, 0, bytes.Length);
            return new string(dst);
        }

Usage Example

        private void Update()
        {
            if (this.m_HostId == -1 || this.m_IsServer)
            {
                return;
            }
            NetworkEventType fromHost;

            do
            {
                int  connectionId;
                int  channelId;
                int  receivedSize;
                byte error;
                fromHost = NetworkTransport.ReceiveFromHost(this.m_HostId, out connectionId, out channelId, this.m_MsgInBuffer, 1024, out receivedSize, out error);
                if (fromHost == NetworkEventType.BroadcastEvent)
                {
                    NetworkTransport.GetBroadcastConnectionMessage(this.m_HostId, this.m_MsgInBuffer, 1024, out receivedSize, out error);
                    string address;
                    int    port;
                    NetworkTransport.GetBroadcastConnectionInfo(this.m_HostId, out address, out port, out error);
                    NetworkBroadcastResult networkBroadcastResult = new NetworkBroadcastResult();
                    networkBroadcastResult.serverAddress = address;
                    networkBroadcastResult.broadcastData = new byte[receivedSize];
                    Buffer.BlockCopy((Array)this.m_MsgInBuffer, 0, (Array)networkBroadcastResult.broadcastData, 0, receivedSize);
                    this.m_BroadcastsReceived[address] = networkBroadcastResult;
                    this.OnReceivedBroadcast(address, NetworkDiscovery.BytesToString(this.m_MsgInBuffer));
                }
            }while (fromHost != NetworkEventType.Nothing);
        }
All Usage Examples Of UnityEngine.Networking.NetworkDiscovery::BytesToString