Пример #1
0
    public void Send(MeshPacket packet)
    {
        //Debug.Log("Send(): Dest. object: " + packet.GetTargetObjectId());
        if (meshnet.database == null)
        {
            Debug.LogError("Trying to send packet when database does not exist.");
        }

        if (packet.GetTargetPlayerId() == meshnet.GetLocalPlayerID())
        {
            ParseData(packet);
            return;
        }

        byte[]   data       = packet.GetSerializedBytes();
        Player[] allPlayers = meshnet.database.GetAllPlayers();
        if (packet.GetTargetPlayerId() == (byte)ReservedPlayerIDs.Broadcast)
        {
            foreach (Player p in allPlayers)
            {
                if (p.GetUniqueID() == meshnet.GetLocalPlayerID() && packet.GetPacketType() == PacketType.TransformUpdate)
                {
                    continue;
                }

                SteamNetworking.SendP2PPacket(new CSteamID(p.GetUniqueID()), data, (uint)data.Length, packet.qos);
            }
        }
        else
        {
            SteamNetworking.SendP2PPacket(new CSteamID(packet.GetTargetPlayerId()), data, (uint)data.Length, packet.qos);
        }
    }
Пример #2
0
    public void SendDirectToSteamID(MeshPacket packet, ulong id)
    {
        CSteamID steamID = new CSteamID(id);

        Debug.Log("Direct sending. You sure you want to do this?");
        //Debug.Log("Dest. object: " + packet.GetTargetObjectId());
        byte[] data = packet.GetSerializedBytes();
        SteamNetworking.SendP2PPacket(steamID, data, (uint)data.Length, EP2PSend.k_EP2PSendReliable);
    }